Thank you for any help in advance. I have a form that the employees fill in the first, last, and DOB of a client and I have a the below script to look at the table to make sure that the name has not already been entered. It works too good. It is finding names that haven't been entered yet. There are names that are close, so that is why i added the DOB to the search to try and define the search. But it is still finding false results. Can anyone tell me what I am doing wrong. Thank you.
Private Sub DOB_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[FirstName]", "tbl_Client", "[FirstName]='" & Me![FirstName] & "'")) And Not IsNull(DLookup("[LastName]", "tbl_Client", "[LastName]='" & Me![LastName] & "'")) And Not IsNull(DLookup("[DOB]", "tbl_Client", "[DOB]=#" & Me![DOB] & "#")) Then
MsgBox "Defendents Name has already been entered into the database.", vbOKOnly & vbCritical, "Defendent Already Exists"
Me.Undo
Dim strDocName As String
Dim strDocNam As String
strDocName = "rpt_ClientSearch"
DoCmd.OpenReport strDocName, acViewReport
strDocNam = "frm_Client"
DoCmd.Close acForm, strDocNam, acSaveNo
End If
End Sub
Private Sub DOB_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[FirstName]", "tbl_Client", "[FirstName]='" & Me![FirstName] & "'")) And Not IsNull(DLookup("[LastName]", "tbl_Client", "[LastName]='" & Me![LastName] & "'")) And Not IsNull(DLookup("[DOB]", "tbl_Client", "[DOB]=#" & Me![DOB] & "#")) Then
MsgBox "Defendents Name has already been entered into the database.", vbOKOnly & vbCritical, "Defendent Already Exists"
Me.Undo
Dim strDocName As String
Dim strDocNam As String
strDocName = "rpt_ClientSearch"
DoCmd.OpenReport strDocName, acViewReport
strDocNam = "frm_Client"
DoCmd.Close acForm, strDocNam, acSaveNo
End If
End Sub