in reply to How do I avoid inserting duplicate numbers into an Access table?

This is a constraint that is best handled in the database itself, not in the code. If you have control over the structure of the database, create a unique index on the field. In access, I believe it's a combo box called "Indexed" - select Yes, No duplicates. In SQL, it'll look like "CREATE UNIQUE INDEX name ON table (column)". Either way, the db will prevent duplicate records.

If (and only if) you have no control over the structure of the database, it's a 2-step procedure. Query the table for records that match (select * where field='no duplicates'). If you get no results, then insert the record. And be wary of race conditions if the db is multiuser!

  • Comment on Re: How do I avoid inserting duplicate numbers into an Access table?