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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to check for duplicate records

Status
Not open for further replies.

LDG1234

Programmer
Jun 26, 2001
120
GB
Hi guys

Can anyone suggest a way in which I can check for duplicates of records. I need it to work like so:

Lets say I have 10 columns in my tables.

As the operator enters the data through a form, after the data is entered into the 3rd field I would like to run a piece of code to check if there are any records which have the identical data in the first 3 fields.

If so I would like to display a message box with the reference number of the records.

I would be grateful if anyone could get me started on this.

Thanks in advance.

Lloyd Gozzett
Process Developer
 
Lloyd,

Done like this.....

1) On the third field, run an update event
2) In the update event, open an recordset with SQL parameters for the first three fields.
3) If the recordcount > 0 then record must exist
4) Show message box with ID.

Craig
 
Craig...

Good tip. I've used something similar in the past. However, Access(2k) seems to save the record with the first three fields anyway...as you go...without hitting the cmdSave button.

Know of a clean way of getting around that?

Thanks,

Tom
 
I'd use the DCount function with the first three column values as the criteria. If it returns >1 (new one) then you know there's a duplicate...
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top