Link to home
Start Free TrialLog in
Avatar of Jeremy Campbell
Jeremy CampbellFlag for United States of America

asked on

Trying to setup a delete query in access based on results of another query.

Here is my Delete query as of right now.
User generated image
I want to delete every row in the tblJobLog where tblJobLog.JobNum = qryJobLogDelCrit.jhJobNum.

Here is the sql for my current delete query;
DELETE tblJobLog.*
FROM tblJobLog INNER JOIN qryJobLogDelCrit ON tblJobLog.JobNum = qryJobLogDelCrit.jhJobNum


When I run this query as a Select query it will give me a list of JobNums that I would like to delete. I thought If I just changed it to a Delete query then it would delete those rows from tblJobLog.

When I try to run it I get the following error message;
User generated image
Thanks for the help!
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeremy Campbell

ASKER

Is that rerunning qryJobLogDelCrit for every record in tblJobLog? Seems like that may be the case because it just hangs.. Is there a quicker method by chance?
What is the SQL for qryJobLogDelCrit?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mbixup.. I'm sorry, I forgot to get all of my extra tables out of that query. qryJobLogDelCrit used to have a bunch of extra tables and calculations in it (I copied it from another table that had a bunch of stuff in it)

Once I deleted all the extra stuff from it, it ran almost immediately.

Thanks for the help there!

Thanks also Capricorn for your offering as well.. It would have solved the problem as well.
It sounds like you're set, but you probably could also work the criteria of qryJobLogDelCrit right into your delete query, to reduce it to a single query.  

That would be my preferred approach if the second query was not overly complex, and was where I was heading asking about the SQL
Gotcha. Thanks again!