Delete Query problem

JHSam

Board Regular
Joined
Feb 17, 2002
Messages
62
Another question with my ongoing adventures in dealing with Access queries ...

I am trying to run a delete query, which removes records in a given field in Table 1 that match those in Table 2. I can set this up OK and when I do a view the dynatable looks like its picking the correct records out to delete, but when I actually run the delete query I get a message "Could not delete from specified tables". I've tried linking and not linking the tables, and including a value in the 'Where' box or leaving it empty.

The SQL is something along the line of the following (I may have messed up the parentheses and brackets since this is an edited copy):
DELETE [Table1].*, Table2.TargetField
FROM [Table1]
WHERE (((Table2.TargetField)=Table1.Target Field));

Any suggestions would be appreciated.

Thanks.

:confused:
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Uncheck the Show box for the field in Table 2. As far as I know, you can only delete records in one table at a time. So the SQL would look something like this:

DELETE [Table1].*
FROM [Table1]
WHERE (((Table2.TargetField)=Table1.Target Field));

Hope this helps,

Russell
 
Upvote 0
Unfortunately that didn't work since there aren't any checkboxes in the delete query. The dynatable showed the linked field, which may be why the query is not running properly.

Why do these things always happen when there are deadlines ...?
 
Upvote 0
Sorry, just paste in the SQL (changing table and field names as necessary). If you change the query to a SELECT query, you can uncheck the box, then change it back to a DELETE query (should work, anyway - not tested).

HTH,

Russell
 
Upvote 0
It still acted up ... I opted for a "Finding Unmatched" make-table Query instead -- sort of a "create by force" approach.

Thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,221,531
Messages
6,160,357
Members
451,642
Latest member
mirofa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top