Solved

find duplicate records in MS Access

Posted on 2003-11-03
3
896 Views
Last Modified: 2011-09-20
Could anyone can tell me how to find all the duplicate records in a table and delete the duplicate? Thanks a lot!
0
Comment
Question by:omanca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 9676852
Try something like:

Delete  from table1 where id in

(

Select ID from Table1 Where [referkey] in (
SELECT [referkey] FROM [Table1] As Tmp GROUP BY [referkey] HAVING Count(*)>1
) And iD not in (        

SELECT  Min(ID) AS MinKey from table1 Group by TAble1.referkey

)

)

?
0
 
LVL 77

Accepted Solution

by:
peter57r earned 100 total points
ID: 9676875
It depends on how many records and duplicates you think you have. and what you want to do in the future.

If you start a new query you have a Find Duplicates query wizard which will show you all occurrences of the duplicated records.
If the numbers are small you could then manually delete the unwanted ones.

If you have too many for that then you you can use a trick.

Copy the table containing the duplicates. (Right-click the table name and select copy)
Paste and select Structure only.  Use a name of your choice.

Now modify the design of the copy to prevent any duplicates occuring.
To do this set the primary key or create a unique index based on the fields which  identify the duplication.

Now create an append query which appends records from the original table to the new table.

When you run this query all duplicates will be rejected and you can rename the old and new tables.

Pete




0
 
LVL 2

Author Comment

by:omanca
ID: 9676910
Thanks Pete,
It was good enough to know that there is a "Find Duplicates query wizard"

Omanca
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question