Question : MS Access Specify Table Error

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?

Answer : MS Access Specify Table Error

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);



Random Solutions  
 
programming4us programming4us