aaabuhalime
Instructor
Hi,
I have a data entry form to add new customers, I have two filds in the form First Name, and Last name field, I am rying to prevent any duplicate entries, I am using the code below to prevent any duplicate entries for both names, it seems I am missing somthing , I have placed the code in the Beforeupdate Property for the LName field it is working fine, what I am trying to do I want he code to check both names then detrmine wether the it is a duplictae entry or not, I need help in what needs to be changed in the code, and where I need to place the code , on the form cutrrent property or on load please help !
any help will be higly appreciated.
Thanks
I have a data entry form to add new customers, I have two filds in the form First Name, and Last name field, I am rying to prevent any duplicate entries, I am using the code below to prevent any duplicate entries for both names, it seems I am missing somthing , I have placed the code in the Beforeupdate Property for the LName field it is working fine, what I am trying to do I want he code to check both names then detrmine wether the it is a duplictae entry or not, I need help in what needs to be changed in the code, and where I need to place the code , on the form cutrrent property or on load please help !
any help will be higly appreciated.
Thanks
Code:
Dim Answer1 As Variant
Dim Answer2 As Variant
Answer1 = DLookup("[FName]", "tblCustomers", "[FName] = '" & Me.FName & "'")
Answer2 = DLookup("[LName]", "tblCustomers", "[LName] = '" & Me.LName & "'")
If Not IsNull(Answer2) And Not IsNull(Answer2) Then
MsgBox "Duplicate Name Found" & vbCrLf & "Please enter again.", vbCritical + vbOKOnly + vbDefaultButton1, "Duplicate"
Cancel = True
Me.FName.Undo
Me.LName.Undo
Else:
End If
End Sub