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

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

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

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

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

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


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

            End If

Recommended Answers

All 2 Replies

Minimalist, thanks for the reference. starting to recode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.