View Full Version : Append if Record Doesnt Exist, Else Update


proballin
02-19-2008, 07:26 AM
I have a table that is filled based on selections that a user makes in combo boxes on a form. I am having trouble trying to figure out the best way to prevent duplicates from being inserted in the table when I do the append query part.

Since the table is filled based on the various selections the user makes I dont have a primary key or unique field.

Can someone help me figure out the best way to do this append/update queries to prevent duplicates. Also if you have a strategy for setting up some sort of unique or primary key for fields that could all be the same yet in the table only 1 record will show, no duplicates.

neileg
02-20-2008, 01:36 AM
You could use DCount() to count the number of matching records in the table. If the count is anything other than 0, don't append.