How to check for duplicate record before inserting
Posted on 2008-11-19
I have a table that I am inserting records into based on certain criteria. The code is as follows:
CurrentDb.Execute ("INSERT INTO [Activities] (ClaimNo, Custodian, Activity, DateStamp) VALUES ('" & Me.pendclaimnum & "','" & Me.Custodian1 & "','PCAC',#" & Int(Now()) & "# )")
I'd like to make it so, if the values of Me.pendclaimnum and PCAC already exist in the table, not to insert them. Would this be achieved by running a select query and then comparing the recordset/results? Not quite sure how to approach this, It needs to run relatively fast as well... Any help would be awesome!