Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DlookUp Run Time Error 3464

Status
Not open for further replies.

DraGo150

IS-IT--Management
May 6, 2009
11
US
Hello, trying to understand what I am doing wrong. I have a DLookup to search the table for duplicate records before update, but it keeps producing an error. Any help would be appreciated.

Private Sub DOB_LostFocus()
If (Not IsNull(DLookup("[LastName]", _
"tbl_Client", "[LastName] ='" _
& Me!LastName & "'"))) Then
If (Not IsNull(DLookup("[FirstName]", _
"tbl_Client", "[FirstName] ='" _
& Me!FirstName & "'"))) Then
If (Not IsNull(DLookup("[DOB]", _
"tbl_Client", "[DOB] ='" _
& Me!DOB & "'"))) Then
Else
MsgBox "Name has already been entered in the database."
Cancel = True
Me.Undo
Dim strDocName As String
strDocName = "rpt_ClientSearch"
DoCmd.OpenReport strDocName, acViewReport

End If
End If
End If
End Sub
 
Replace this:
"tbl_Client", "[DOB] ='" _
& Me!DOB & "'"))) Then
with this:
"tbl_Client", "[DOB] =#" _
& Format(Me!DOB, "yyyy-mm-dd") & "#"))) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you PHV

That worked... :)

Just for my understanding the ' is for text and the # is for numbers?

 
The # is for dates.
Numbers don't need delimiters.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top