duplicate fields on table

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?
 
G

Graham Mandeno

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.
 

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

Similar Threads

Duplicate pst, or is it? 1
Weekly Report 2
Copy previous record into form field 0
M.S. Word 365 1
Outlook - Catgorizing emails by names 0
Split form 0
Need some PWA help 0
No duplicate records problem 17

Top