Do not allow duplicates - corrected

dbaldwin117

New member
Local time
Today, 02:12
Joined
Jan 21, 2011
Messages
6
I need to use a non-key field that is not indexed but will not allow duplicates. How can this be done?
 
If you ensure that data is only entered via a form, then you could do it in the Before Update event of the form and you can use a DCount to check to see if the value exists and if so, cancel the update and message the user.

If DCount("*", "TableOrQueryNameHere", "[FieldNameHere] = " & Me.YourControlNameHere) > 0 Then

or if the field is text:


If DCount("*", "TableOrQueryNameHere", "[FieldNameHere] = " & Chr(34) & Me.YourControlNameHere & Chr(34)) > 0 Then
 

Users who are viewing this thread

Back
Top Bottom