A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Delete Records from Table using Query Results



 
 
Thread Tools Display Modes
  #1  
Old May 7th, 2010, 04:38 PM posted to microsoft.public.access.queries
SITCFanTN
external usenet poster
 
Posts: 49
Default Delete Records from Table using Query Results

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!
  #2  
Old May 7th, 2010, 05:18 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Delete Records from Table using Query Results

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!

  #3  
Old May 10th, 2010, 07:51 PM posted to microsoft.public.access.queries
SITCFanTN
external usenet poster
 
Posts: 49
Default Delete Records from Table using Query Results

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!

.

  #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!

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.