Check for Duplicates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field that I have set as "No Duplicates" in the table view. But it only tells me if a duplicate is entered after I fill out the rest of the form and save it. I would like to set it so that "On Exit" it checks for duplicates and prompts the user that it isn't allowed because of duplicates. If anyone can help me that would be great
Thank
Christina
 
Christina said:
I have a field that I have set as "No Duplicates" in the table view. But
it only tells me if a duplicate is entered after I fill out the rest of the
form and save it. I would like to set it so that "On Exit" it checks for
duplicates and prompts the user that it isn't allowed because of
duplicates. If anyone can help me that would be great!
Thanks
Christina

BeforeUpdate would be better. Example below assumes a Text field. For a
numeric field you would remove the single quotes.



If DCount("*", "YourTableName","YourFieldName = '" & Me!YourFieldName &
"'") > 0 Then
MsgBox "Duplicate Value"
Cancel = True
End If
 
This is the code I used, but it's coming up with an error in the first line. Do you see anything wrong with this
Thank

If DCount("*", "Client_Info", "Client_Number = '" & Me!Client_Number & "'") > 0 The
MsgBox "Duplicate Client Number
Cancel = Tru
End If
 
Back
Top