duplicate data and validation rule

R

Ranch Hand

My Form has a unique IDNumber, no duplicates; I wrote the following code to
produce a warning immediately after leaving the IDNumber cell in the event of
a dupl (instead of waiting until the entire form was filled in). Now I also
get an error message: "Value in field or record violates validation rule for
record or field."

I have not changed the validation rule (in fact, there is no validation rule
except that it is the primary number.

The event procedure code is:

Private Sub IDNumber_BeforeUpdate(Cancel As Integer)
If IDNumber = DLookup ("IDNumber" , "My Database" , "[IDNumber] = "&
IDNumber) Then MsgBox "Already exists."

Cancel = True

End If

End Sub

I'm pulling my hair out and don't have any to spare. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top