Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a query from another query 1

Status
Not open for further replies.

mbowler9

IS-IT--Management
Joined
Sep 8, 2003
Messages
105
Location
US
I have Access linked to a read only database. To create some queries I had to create my own tables via "make table queries". To ensure that my queries are up to date when I run them, I need to run the "make table queries" or some sort of update query BEFORE I run my desired query.

For example: I want to run query A, but I need to run query B to update the information in the tables that A uses. Is there a way to call query B before query A?

Here is my current SQL for the make table query I have.

Thanks in advance.

SELECT allmid_cpu.vendor, allmid_cpu.model INTO models
FROM allmid_cpu
GROUP BY allmid_cpu.vendor, allmid_cpu.model
HAVING (((allmid_cpu.model)<>&quot;Unknown&quot;))
ORDER BY allmid_cpu.vendor, allmid_cpu.model;
 
Hi use a macro is the easiest. Have the macro run you first query (B) to make the table and then run the query (A) on the result.
 
I have never really used a macro before. I will be running the queries with VBA and saving them to Excel. I can run it easily with VBA and would prefer to, but here are my concerns.

1) What event tells me that query B has finished so I can run query A?

2) I get a prompt asking something along the lines &quot;is it ok to replace the data in the table&quot; for which I would need to answer &quot;yes&quot; automatically.

Any suggestions?

Thanks
 
Hi

In VBA have the first query run eg
DoCmd.OpenQuery &quot;Query1&quot;, acNormal, acEdit
then have
DoCmd.OpenQuery &quot;Query2&quot;, acNormal, acEdit
query2 will only start after query1 has finished.

To stop the warning have at the start of your statement
DoCmd.SetWarnings False
and at the end
DoCmd.SetWarnings True

Hope that helps
 
Thanks. It worked perfect.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top