Full Version: Delete Query based on multiple criteria not working
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
mjhopler
I have a data base with a table. I have created a query that returns a specified data and want to deleted that data from the original table. However, the query is based off criteria of the table and another query. When I try to run the delete query, it returns the error message "Specify the table containing the records you want to delete."

How can I make this work? See the attached.
KimbleG
Hi,
I think your problem is the circular nature of your delete query.

I would remove Query1 from your SQL statement and use

DELETE [Property Financials].*, [Property Financials].[Property ID]
FROM [Property Financials]
WHERE ((([Property Financials].[Property ID])<>12345));

HTH

Kimbo
theDBguy
QUOTE (mjhopler @ Apr 8 2010, 11:42 AM) *
I have a data base with a table. I have created a query that returns a specified data and want to deleted that data from the original table. However, the query is based off criteria of the table and another query. When I try to run the delete query, it returns the error message "Specify the table containing the records you want to delete."

How can I make this work? See the attached.

Hi,

As an alternative...

Make sure you have a backup copy before trying this:

CODE
DELETE DISTINCTROW [Property Financials].*
FROM [Property Financials]
LEFT JOIN Query1
ON [Property Financials].[Property ID] = Query1.[Property ID]
WHERE (((Query1.[Property ID]) Is Null));


Hope that helps...
rwu
I have a problem similar to the post from 2 years ago here. Details are a little more involved. We have a training database that has a link to a table in SharePoint elsewhere on the company server called "Employee Directory". This directory is kept current. The "Registration" table contains the training information entered on a periodic basis. At least once a year, we will want to run a delete query to delete the employee data for employees that have left the company. I can get the select query to pull out the information by showing the "Registration" table and the last and first names of the employees from the "Employee Directory". The criteria for the "Employee Directory" names is set to "Is Null". But running it as a delete query produces the same response as mjhopler's.

One way that it works is to follow KimbleG's suggestion - remove the "Employee Directory" table and set the criteria for the name of the employee who left. But this means that we would have to change it and run it separately for every employee. Is there a way to do it with keeping the link to the "Employee Directory" table, as with the select query? (I did not follow theDBguy's suggestion so I'm not sure how or if it would work.)
theDBguy
Hi,

welcome2UA.gif

What version of Access are you using?

May I suggest that you give my suggested solution a try and if it doesn't work, I would also suggest that you start a new thread to get a better chance of others seeing your question and offering you a solution.

Just my 2 cents... 2cents.gif
rwu
Using Access 2010.

Tried your solution and it told me to specify the table containing the records I want to delete.

I'll restart this question on a new thread.
theDBguy
Okay... Good luck!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.