Delete Query...Doesn't!!! (1 Viewer)

shuff

Registered User.
Local time
Today, 02:44
Joined
Oct 13, 2000
Messages
61
I want to execute a delete query on a table of account records. The query contains two tables linked on account number, one with a list of unique records, linked to the other with "many" records to be deleted. For each unique record from table A, I want the delete query to delete all records with a matching account number in table B. However, I get a message stating that I "could not delete from the specified table." Huh???

I can manually delete from table B, or I can get the query to work if I don't try using table A as the control table and instead specify literal criteria. I have tried all three join types but still no luck. Any ideas?

Many thanks in advance for any help provided-

SLH
 

Brianwarnock

Retired
Local time
Today, 02:44
Joined
Jun 2, 2003
Messages
12,701
Make sure that the SQL says

DELETE DISTINCTROW tablename etc

Brian
 

Moniker

VBA Pro
Local time
Yesterday, 20:44
Joined
Dec 21, 2006
Messages
1,567
You can't delete from the one side of a one-to-many relationship. Build a quick temp table containing the IDs you want to delete, and then separately delete them from each table. There are "smoother", more elegant ways to do this, as it were, but this is the most straightforward.
 

Users who are viewing this thread

Top Bottom