[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MS Access Specify Table Error

Posted on 2009-12-23
6
Medium Priority
?
384 Views
Last Modified: 2013-11-27
I'm getting a "Specify the table containing the records you want to delete." Error.

This is the code I've generated from the Access GUI following the delete query tutorial:
DELETE Customers.*, Customers.[Last Name], Customers.[First Name], Customers.ID, Customers.Company
FROM [Customers - Distinct Query] AS [Distinct] INNER JOIN Customers ON Distinct.[Last Name] = Customers.[Last Name]
WHERE (((Customers.[Last Name])=[Distinct].[Last Name]) AND ((Customers.[First Name])=[Distinct].[First Name]) AND ((Customers.ID)<>[Distinct].[MinOfID]) AND ((Customers.Company)=[Distinct].[Company]));


I want to delete the fields in table Customers that are completely duplicated.  I'm using the ID field, which is the autonumber primary key, to choose which one is to be deleted, using the MinOfID key.  Could you help?
0
Comment
Question by:jbgames
  • 4
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
calpurnia earned 2000 total points
ID: 26116527
I don't believe you can use a join in the FROM clause in a DELETE statement.
The following should do what you're after (but usual warnings apply - try it out on a spare copy of your data first!)

DELETE * FROM Customers C1
WHERE C1.ID NOT IN
(SELECT Min(C2.ID) FROM Customers C2
GROUP BY C2.[Last Name], C2.[First Name], C2.Company);



0
 

Author Comment

by:jbgames
ID: 26116533
What does the C1 / C2 do?  Do I need to change things in my setup first?
0
 

Author Comment

by:jbgames
ID: 26116535
Thank you so much!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:jbgames
ID: 26116539
It worked!  No more info needed!
0
 

Author Closing Comment

by:jbgames
ID: 31669635
Awesome!!!
0
 
LVL 10

Expert Comment

by:calpurnia
ID: 26116655
For the record, C1 and C2 are aliases, or short 'nicknames' given to the Customers table. Aliases help to make queries more readable and avoid ambiguity. In this particular case it wasn't essential to use them, but there are some queries containing subselects where you would have to use them.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

831 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