0

I have two tables [Month Bill Final] and [New Research Members Final] that share many of the same fields and data. I need to delete records in [Month Bill Final] that have a value of "Duplicate SSN" in the [Research Flag] field in [New Research Members Final] table. I have joined the tables on the fields in the SQL below, but I kept getting the error "Could not delete from specified tables".

DELETE [Month Bill Final].*, [New Research Members Final].[Research Flag]
FROM [Month Bill Final] INNER JOIN [New Research Members Final] ON ([Month Bill Final].[First Name] = [New Research Members Final].[First Name]) AND ([Month Bill Final].[Last Name] = [New Research Members Final].[Last Name]) AND ([Month Bill Final].[Date of Birth] = [New Research Members Final].[Date of Birth]) AND ([Month Bill Final].[Subscriber SSN] = [New Research Members Final].[Subscriber SSN]) AND ([Month Bill Final].[Employee SSN] = [New Research Members Final].[Employee SSN])
WHERE ((([New Research Members Final].[Research Flag])="Duplicate SSN"));
Chuck0185
  • 531
  • 3
  • 15
  • 36
  • Have you seen https://stackoverflow.com/questions/4807438/delete-records-from-multiple-tables-in-access-2007 ? – Caius Jard Nov 30 '17 at 16:30

2 Answers2

0

You can only target one table in a DELETE statement. Remove , [New Research Members Final].[Research Flag] from your SQL.

John Mo
  • 1,326
  • 10
  • 14
0

Using joins in action queries can create ambiguous results. Avoid them. There also should be nothing between DELETE and FROM. Try this:

DELETE 
FROM [Month Bill Final] 
WHERE EXISTS
(
SELECT '1'
FROM [New Research Members Final] 
WHERE [Month Bill Final].[First Name] = [New Research Members Final].[First Name]
AND [Month Bill Final].[Last Name] = [New Research Members Final].[Last Name] 
AND [Month Bill Final].[Date of Birth] = [New Research Members Final].[Date of Birth] 
AND [Month Bill Final].[Subscriber SSN] = [New Research Members Final].[Subscriber SSN]
AND [Month Bill Final].[Employee SSN] = [New Research Members Final].[Employee SSN]
AND [New Research Members Final].[Research Flag]="Duplicate SSN"
);
Rene
  • 1,095
  • 1
  • 8
  • 17