By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,212 Members | 1,369 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,212 IT Pros & Developers. It's quick & easy.

Deleting 1 of 2 identical records

P: 1
Hi,

Is it possible to delete only 1 record when you have 2 duplicate records in a table. Normally i would do a group by query, but in some cases there are records where i want duplicates and also sometimes there are 3 duplicates and i only want to delete 1 of them.

Is this possible?

Thanks in Advance

Chris Clarke
Jan 22 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 446
Hi Chris

I would suggest there is something wrong with your database design if you WANT duplicate records. Most of us go to extreme lengths to PREVENT them !

If they arise from User input I would suggest you add a new field, call it X for the moment, then when the last user's field has been entered do something like;
Expand|Select|Wrap|Line Numbers
  1. Me!X = Dcount("AnyField","CurrentTableName","[Field1]=" & Me!Field1 & " and [Field2]=" & Me!Field2 & "etc, etc)
That way you will know which entries have duplicates and how many.

But I have no idea how you would deal with them

If the data is already entered I would use a similar approach (add field X ).
I would then create a Recordset based on a query where there is a sort on each field (effectively grouping the duplicates), then set-up a loop to compare each record with the next. (how many fields are you testing on?)

If the fields are the same then X= X+1, else X =0 and save each of the current fields as data for the next criteria

Can you manage the code?

Best of luck

S7
Jan 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.