![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I'm a relatively new VBA programmer but have been given the task of repairing a database that currently appears with "3146 ODBC--call failed." This happens when various criteria are input into a form (called InvCredit), and then cmdProcess is clicked. Then we are asked if we can "Confirm you want to process?" and when Yes is clicked the error appears. Following is the code. I have found that the break appears at the .Update point close to the bottom. Thanks, J.Meager Private Sub cmdProcess_Click() On Error GoTo handler If MsgBox("Confirm you want to process", 292) = vbNo Then Exit Sub Dim db As DAO.Database Dim rsReq As DAO.Recordset Dim strSQL As String Dim dteLoop As Date Dim lngInvNo As Long dteLoop = Format(DateFrom, "long date") Set db = CurrentDb strSQL = "SELECT DateRequired,SchoolCodeID,Required,InvoiceNumber,I nvoiceDate,ProductID,InvCred,RequirementsID FROM tblRequirements;" Set rsReq = db.OpenRecordset(strSQL, 2, dbSeeChanges, 2) lngInvNo = DLookup("[Next Invoice Number]", "Control") strSQL = "UPDATE Control SET [Next Invoice Number]=[Next Invoice Number]+1;" db.Execute strSQL With rsReq Do .AddNew !DateRequired = dteLoop !SchoolCodeID = SchoolName '!Required = AdjustmentQuan !Required = Nz(Me(Format(dteLoop, "dddd")), 0) !InvoiceNumber = lngInvNo !InvoiceDate = Date !ProductID = Products.Column(3) Debug.Print Format(dteLoop, "dddd") !InvCred = IIf(Nz(Me(Format(dteLoop, "dddd")), 0) < 0, 1, 0) .Update dteLoop = dteLoop + 1 Loop Until dteLoop > Format(DateTo, "long date") End With DoCmd.OpenReport "InvoiceInvCred", acViewPreview, , "InvoiceNumber=" & lngInvNo Exit Sub handler: Select Case Err.Number Case 3022 Resume Next Case Else MsgBox Err.Number & " " & Err.Description End Select End Sub |
![]() |
| Thread Tools | |
| Display Modes | |
| |