Hello Everyone,
I am using a code to check if the name exists in a table and if it does then gives an error message and returns back to same field and empties it out.
The form has a field called Customer_Name which is need to check in table tblCustomerInformation.
Im using this:
Private Sub Customer_Name_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[Customer_ID]", "tblCustomerInformation", "[Customer_Name] = '" & Me.Customer_Name & "'")) Then
MsgBox "Name Exists!""" _
& vbCrLf & " " _
& vbCrLf & "Please Try Again.", vbExclamation
Me.Customer_Name = Null
DOB.SetFocus
Customer_Name.SetFocus
End If
End Sub
But it keeps returning a runtime error.
Any Help would be appreciated.
I am using a code to check if the name exists in a table and if it does then gives an error message and returns back to same field and empties it out.
The form has a field called Customer_Name which is need to check in table tblCustomerInformation.
Im using this:
Private Sub Customer_Name_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[Customer_ID]", "tblCustomerInformation", "[Customer_Name] = '" & Me.Customer_Name & "'")) Then
MsgBox "Name Exists!""" _
& vbCrLf & " " _
& vbCrLf & "Please Try Again.", vbExclamation
Me.Customer_Name = Null
DOB.SetFocus
Customer_Name.SetFocus
End If
End Sub
But it keeps returning a runtime error.
Any Help would be appreciated.