duplicate fields on table

  • Thread starter Thread starter Ruben
  • Start date Start date
R

Ruben

I am assigning a number to each person on the table but do not want that
number to duplicate. After entering all the information of that person which
is about 10-12 fields before going to the next record i will get that error
message saying that i just duplicated a field. Is there a way to catch the
duplicate before entering the whole information on all fields?
 
Hi Ruben

Use the BeforeUpdate event of the textbox where you are entering the number.
Your code should use DLookup to check for the existence of that number in
the existing records:

If Not IsNull( DLookup( "YourFieldName", "YourTableName", _
"[YourFieldName]=" & YourTextboxName ) Then
MsgBox "That number has already been used"
Cancel = True
End If

Do the numbers have any particular meaning? If not, then why not make that
field an AutoNumber and Access will take care of everything for you.
 
Back
Top