Access 2007-2013
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us  
 

News      User Comments     History     Notify Me

7/28/2008 3:21:03 PM
Access Tip: Duplicate Records in Two Tables
By Richard Rost   Richard Rost on Facebook Richard Rost on Twitter Richard Rost on Google Plus Richard Rost on LinkedIn Email Richard Rost
 
Q: I have two tables with customer information. I need to keep the two tables separate, but I would like to delete the duplicates from one of the tables (i.e. delete the customers from table A who are also in table B)?

A: There's really no easy way to take two tables and delete the duplicate records between them. There is a FIND DUPLICATES query, but that only searches for duplicate RECORDS in a single table... which you could do, if you could merge both tables together and then delete all of the duplicates.

Here's my cheap workaround for finding duplicate records between two tables. This assumes you have a field in them (such as CustomerID) that is the same for both tables.

Step 1: add a field in the table that has the records you want to delete called DeleteMe - or something to that effect.

Step 2: JOIN these two tables together in a query by whatever field is related so that when you run the query you see only records that are in both.

Step 3: convert this query over into an UPDATE query. Now, update the value of the DeleteMe field to YES. See this tutorial for help on Update queries:

  /tips/access/update-query

Step 4: run the query. Now every record that is in BOTH tables (since they're joined) will be marked YES for DeleteMe.

Step 5. Make a new query based on just the table with records that need to be deleted, and set the criteria so DeleteMe = TRUE.

Step 6. Convert this query over to a DELETE query. This should delete only those records.

If you need more help with ACTION QUERIES (make table, delete, update, append, etc.) I cover them in exquisite detail in my Access 222 Tutorial:

  /site/courselist/access/access222


Hope this answers your question.

Permanent Link
Keywords: access tips update query delete action
Post Reply

duplicates Comment from Richard Rost @ 7/29/2009
Carolyn, you can import them all into Access and then use Access to delete the duplicates. There is a FIND DUPLICATES query wizard. Try that.
Show Just This Thread        Post Reply
duplicates Comment from Carolyn Quinn @ 7/28/2009
I have a table full of dupes.  Oh my goodness.  There are so many, yet they have their own uniqueness.  I am not sure how to delete them or if i should delete a few at a time; for instance, they all have an account name, Regional VP, Regional Director, Acct Number, budget number, Division VP and opening date.  These fields are all thed same for every account.  Then it has six programs, then they have about 8 brands, and then the 8 retail items.   This information is in Excel and i know it needs to go to Access, but i need to delete the dupes first.  It hard be cause one category says coffee, but there are 12 different coffees to choose from and one account could have all of them which is why the duplicate lines because each lines signifies another type of coffe.  I want to stop and start a database with relationships, but time won't permit me for this first report, but going forward i can.  What options do i have?
Show Just This Thread        Post Reply
Comment from Richard Rost @ 9/8/2008
Eric, I've got no idea. I'd have to see this database to tell you for sure. If the whole form just goes BLANK, that tells me that Access is out of system resources (memory). Have you tried just rebooting?
Show Just This Thread        Post Reply
Comment from Eric @ 8/31/2008
I am trying to create a form with multiple combo boxes from several different tables.  I can do it with one combo box from one table, but as soon as I add a third, the table becomes invisible in form view, even though I can still work with it in design view.  Any suggestions?
Show Just This Thread        Post Reply

Add Your Comments or Subscribe
 
If you just want to subscribe to get email updates when the News is updated, then enter your name and email address and check the Notify Me box below. If you would optionally like to add your comments below to be posted, they are welcome.
 
  Your Name:  Required
  Your Email:  NOT Public
  Subject:
  Comments:

 

Sorry about this step. It's just to keep the spam bots away:
  Verify: What is 5+3:
  
  Notify me when the News is updated.
  Remember Me for my next comments
  
 
 
Please do not use this form for Customer Service inquiries! If you have questions about your account, shipping info, courses you've ordered, need passwords, etc. please use the Customer Service Center instead.

I value your comments. They will be displayed on this page (above). Your name will be displayed, but your email address will not be.
As always, I promise to never give away your personal information to anyone else, ever.

NOTE: If you don't leave your name and email address, DON'T expect a reply. I can't promise a personal reply to everyone who posts here. I TRY my best, but I cannot guarantee it. If you don't leave your real name and email address, I won't even bother. I usually just hit DELETE. -Richard

 

 

You may want to read these articles from the 599CD News:

7/16/2014Microsoft Access Expert 24
7/15/2014Access 24 Finished
7/14/2014Windows 8.1 Delayed for Access 24
7/3/2014Microsoft Access Expert 23
6/30/2014Access 23, Windows 2
6/17/2014Weekly Access Hangout
6/2/2014Microsoft Access Expert 22
6/1/2014Access 22 Recorded
5/31/2014Working on Access 22 Today
5/18/2014Microsoft Access Expert 21
 

Learn
 
Accessindex
Excelindex
Wordindex
Windowsindex
PowerPointindex
Photoshopindex
Visual Basicindex
ASPindex
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
Free Upgrades
Insider Circle
Student Databases
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Articles
Search Our Site
Waiting List
Production Schedule
Collapse Menus
Help
 
Live Chat
Customer Support
WalkThru Tutorials
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Gift CDs
Contact
 
Live Chat
General Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

Google Plus    LinkedIn

Blog RSS Feed    YouTube Channel
Richard Rost Microsoft MVP