Using a Form for entries, how do I prevent duplications?

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

Guest

Using MS Access 2003, I created a database. I am entering data records using
a form. How do I set up a search of the table to assure that the record was
not previously entered?
 
If you define primary keys and/or unique indexes, Jet will take care of this
for you. It is better to let the database engine enforce this type of rule.
If you want to trap the error and replace the message with one of your own,
use the onError event of the form.

Since most data entry is accurate, it is not cost effective to validate it
first. The other problem with validating it first is that in a multi-user
environment, things may happen quickly and it is quite possible to make your
validation lookup and find nothing and yet by the time your record is
actually inserted, you find that someone beat you to it.
 
Using MS Access 2003, I created a database. I am entering data records using
a form. How do I set up a search of the table to assure that the record was
not previously entered?

You can use the BeforeUpdate event of the Form, or (better, usually)
of the textbox(es) of the field(s) which identify a duplicate. Use
DLookUp to look in the table for a duplicate record, cancel the
update, and warn the user using the MsgBox() function.

Post back with some more details about your table and about what
constitutes a duplicate if you need help with the code. It's not very
difficult.

John W. Vinson[MVP]
 
Back
Top