Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding New Records ONLY

Status
Not open for further replies.

OrWolf

MIS
Mar 19, 2001
291
I have a form that is connected to a database. I'm using a SQL INSERT INTO command to add new records. However it's allowing duplicates to be input and I'd like to avoid this. Any ideas on how I can limit this?
 
One easy way is adding one ID field (autonumber field) in your database. Insert then check for error, if has error of duplicated records then display error message.

Other way is you have to "select from ..." to see if you get any records from the database before Inserting.

 
Another approach without error messages --

As phuctran suggested, just add a primary key field -- which would distinguish what was a duplicate field, and then in the code, set 'on error resume next' and just go to town on your inserts. Only uniques will be added, and no error messages will be thrown -- that is, of course, unless you want them. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top