I get that error when trying to create an error message when entering duplicate employee name by attaching to a field with a list box to the before update event. Here is the code I am using and I have tried everything including renaming the table so there is not a space between Behavioral Rating. Can anyone help?
Code:
Private Sub Employee_Name_BeforeUpdate(Cancel As Integer)
Dim Answer As Variant
Answer = DLookup("[Employee_Name]", "tblBehavioralRating", "[Employee_Name] = '" & Me.Employee_Name & "'")
If Not IsNull(Answer) Then
MsgBox "Employee Record already exists" & vbCrLf & "Please use Find Record to Edit Button.", vbCritical + vbOKOnly + vbDefaultButton1, "Duplicate"
Cancel = True
Me.Employee_Name.Undo
Else:
End If
End Sub
Comment