I have an old access 2.0 database, i converted it in access 2007
but the old code doesn't work.. i heard that it is about DAO and ADO
anyone can help me to convert this DAO code to ADO coding..
thank you so much in advance..

Private Sub cmdSave_Click()
            Dim db As Database
            Dim recGate2 As Recordset
            Dim qdfReleaseGate2 As QueryDef

            Dim intReceived As Integer
            Dim intReleased As Integer
            Dim lngGate2ID As Long

            DoCmd.Hourglass True

            'Get received pieces.
            GetSQL "select isnull(sum(ReceivedPieces),0) Received from tblManifestEntry where MasterAWB = '" & txtMasterAWB & "' and HouseAWB = '" & cboHouseAWB & "' and BatchNo = '" & lstManifestEntry & "'"
            intReceived = grecSQL!Received
            grecSQL.Close

            'Get released pieces.
            GetSQL "select isnull(sum(Gate2Pieces),0) Released from tblGate2 where MasterAWB = '" & txtMasterAWB & "' and HouseAWB = '" & cboHouseAWB & "' and BatchNo = '" & lstManifestEntry & "'"
            intReleased = grecSQL!Released
            grecSQL.Close

            If IsNull(txtMasterAWB) Then
                MsgBox "Enter a valid Master AWB."
                txtMasterAWB.SetFocus
            ElseIf lstManifestEntry.ListCount = 0 Then
                MsgBox "Select a valid House AWB."
                cboHouseAWB.SetFocus
            ElseIf lstManifestEntry.ListIndex = -1 Then
                MsgBox "Select a valid batch."
                lstManifestEntry.SetFocus
            ElseIf txtPendingPieces < 1 Or Not IsNumeric(txtPendingPieces) Then
                MsgBox "Number of pieces must be a value greater than 0."
                txtPendingPieces.SetFocus
            ElseIf txtPendingPieces + intReleased > intReceived Then
                MsgBox "The total number of released pieces will exceed the total number of received pieces in the selected batch."
                txtPendingPieces.SetFocus
            Else

                Set db = DBEngine(0)(0)
                Set recGate2 = db.OpenRecordset("tblGate2", DB_OPEN_DYNASET, DB_APPENDONLY)

                'Get Gate2ID.
                GetSQL "GetGate2ID"
                lngGate2ID = grecSQL!Gate2ID
                grecSQL.Close

                recGate2.AddNew
                recGate2!Gate2ID = lngGate2ID
                recGate2!MasterAWB = txtMasterAWB
                recGate2!HouseAWB = cboHouseAWB
                recGate2!BatchNo = lstManifestEntry

                recGate2.Update


                cmdClear_Click
                txtDateAndTime = Null
                MsgBox "The cartons have been released."

            End If
This article has been dead for over six months. Start a new discussion instead.