Comparing Dcounts to test for a duplicate record

elmop2005

New member
Local time
Today, 15:58
Joined
Feb 9, 2012
Messages
8
i need to do a Dcount before and after and insert into statement i have the inser into part working now but how would i do the two dcounts so that access looks to see if there has been a change to number of records therefore testing for a duplicate.

the field to dcount would be productID, so if the second dcount is one more after the insert it isnt a duplicate as it has worked but if is the same it hasnt and therefore a duplicate.
 
dcount productID, T_order_line, productID > 0 )
insert into ........
if dcount productID, T_order_line, (the first dcount +1) then
msg box "this is a duplicate"

this is basically what im trying to do, how can i compare the two dcounts and see if it has changed after the insert into
 
Save the first dcount to a variable, then when you do the second dcount compare that to the variable.

CountBeforeInsert=DCount()
Insert Into...
If (CountBeforeInsert=DCount()) Then MsgBox("Error")
 

Users who are viewing this thread

Back
Top Bottom