Syntax Error

  • Thread starter Thread starter Joy
  • Start date Start date
J

Joy

In my database I have the following code to search for
possible duplicate records based upon CaseID and CaseType
ID. As the user types in the InsPolicyOrAcctNo, the
database searches for the possible duplicate. This code
worked fine, proviing a soft edit for possible duplicates
until I changed the tab order on the form. Now I get this
error and I just can't seem to understand why tab order
would mess with the code. The error is Run-time
error "3075" Syntaxs error (missing operator) in query
expression '[CaseTypeID]= AND[InsPolicyOrAcctNo]=
0000000000000"

Here is the code I'm using:

Private Sub InsPolicyOrAcctNo_Exit(Cancel As Integer)

Dim strExistingCaseID As String

strExistingCaseID = Nz(DLookup
("[CaseID]", "tblCases", "[CaseTypeID]=" & Me.CaseTypeID
& " AND [InsPolicyOrAcctNo]='" & Me.InsPolicyOrAcctNo
& "'"), "")

If strExistingCaseID <> "" Then
MsgBox "A possible duplicate case was created on "
& DLookup("[DateReceived]", "tblCases", "[CaseID]='" &
strExistingCaseID & "'") & "." & vbCrLf & vbCrLf & "Please
refer to this case ID: " & strExistingCaseID, vbOKOnly +
vbExclamation, "Warning"
End If

End Sub
 
You don't have a value for CaseTypeID. You may need to move the code to the
CaseTypeID Exit or After Update.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

help with code 9
DLookup Error 1
Error 3075 Syntax Error 5
Syntax Error - INSERT INTO Statement 4
duplicate records 2
Syntax Error in Query Expression 2
Syntax error using dlookup 4
basConcatenate on New records 2

Back
Top