View Single Post
  #4  
Old May 11th, 2010, 01:46 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Delete Records from Table using Query Results

That indicates to me that the table Transfer contains all the customer numbers
that are in the table Records. If that is the case you need a way to delete
just the duplicates.

The next step is to determine which records in the Records table you want to
keep. If you have several records with the Customer Number 12345, what
criteria would you use to determine which record to retain? Or does it matter
which record you retain?

There are several techniques that can be used depending on the design of your
database and what relationships (if any) are defined that involve the Records
table.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

SITCFanTN wrote:
Hi John,

When I use the delete query you gave me, all the records I have in table
named "Records" are deleted. I just need the records deleted that contains a
duplicate "Customer Number" in the table "Records" and that also appear in
table "Transfer". Do you have any idea what I could be doing wrong. I'm
using exactly what you gave me below. As always I appreciate your help,
thank you.

"John Spencer" wrote:

Use a delete query

DELETE
FROM Records
WHERE [Customer Number] in
(SELECT [Customer Number] FROM Transfer)

In query design view
== Add the table Records
== Select the customer number into the list of fields
== Select Query: Delete from the menu
== Enter the criteria under the customer number field
in (SELECT [Customer Number] FROM Transfer)

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

SITCFanTN wrote:
I have a table named "Records" that contains a field "Customer Number". I
need to delete all the records in table "Records" if the "Customer Number" is
also in the table named "Transfer". Is there a simple way to accomplish
this? Thank you!

.