G
Guest
Below is the code I have written to load data into various parts of a
database, It falls over at the first "IF" statement, What am I doing wrong?
The error message is as follows "Error No: 2465, Description: Microsoft
Office Access can't find the field '|' referred to in your expression.
Private Sub cmdSLGLInput_Click()
On Error GoTo ErrorHandler
DoCmd.SetWarnings False
DoCmd.OpenQuery "qappSLInvValueGross"
If [tblSalesInvoice]![AccountCodeVAT] = 2205 Then
DoCmd.OpenQuery "qappSLInvValueVAT"
ElseIf [tblSalesInvoice]![AccountCode1] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue1"
ElseIf [tblSalesInvoice]![AccountCode2] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue2"
ElseIf [tblSalesInvoice]![AccountCode3] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue3"
ElseIf [tblSalesInvoice]![AccountCode4] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue4"
ElseIf [tblSalesInvoice]![AccountCode5] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue5"
ElseIf [tblSalesInvoice]![AccountCode6] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue6"
End If
DoCmd.SetWarnings True
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & _
Err.Description
Resume ErrorHandlerExit
End Sub
database, It falls over at the first "IF" statement, What am I doing wrong?
The error message is as follows "Error No: 2465, Description: Microsoft
Office Access can't find the field '|' referred to in your expression.
Private Sub cmdSLGLInput_Click()
On Error GoTo ErrorHandler
DoCmd.SetWarnings False
DoCmd.OpenQuery "qappSLInvValueGross"
If [tblSalesInvoice]![AccountCodeVAT] = 2205 Then
DoCmd.OpenQuery "qappSLInvValueVAT"
ElseIf [tblSalesInvoice]![AccountCode1] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue1"
ElseIf [tblSalesInvoice]![AccountCode2] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue2"
ElseIf [tblSalesInvoice]![AccountCode3] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue3"
ElseIf [tblSalesInvoice]![AccountCode4] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue4"
ElseIf [tblSalesInvoice]![AccountCode5] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue5"
ElseIf [tblSalesInvoice]![AccountCode6] Is Not Null Then
DoCmd.OpenQuery "qappSLInvValue6"
End If
DoCmd.SetWarnings True
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & _
Err.Description
Resume ErrorHandlerExit
End Sub