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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting a group of queries into a macro

Status
Not open for further replies.

eerich

IS-IT--Management
Nov 2, 2003
124
US
Is it possible to setup a group of queries and then copy the entire group into a macro at once?

Also, once they are inserted, and the 'openquery' action is set, is there a way to set the data mode for all queries to 'readonly' instead of 'edit'?

Thanks.
 
Can you please elaborate what you are trying to do?

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
I have 23 queries that I would like to setup to run as a batch through a single macro. I'm hoping there is a method whereby I can just create a group in the query view and include all the queries, then attach that group to a macro and have it execute and export the results to Excel files. Once exported, I have a utility that can load all of the individual excel files into one workbook.

As for the data mode, I need to make sure the openquery is set to 'readonly' vs. edit, because in 'edit' mode, it seems the queries are executed then deleted.
 
You can do it with "OutputTo Method" in vba
Code:
Private Sub cmdOutput_Click()
    DoCmd.OutputTo acOutputQuery, "MyQuery1", acFormatXLS, "C:\MyQuery1.xls"
    DoCmd.OutputTo acOutputQuery, "MyQuery2", acFormatXLS, "C:\MyQuery2.xls"
    DoCmd.OutputTo acOutputQuery, "MyQuery3", acFormatXLS, "C:\MyQuery3.xls"
End Sub
It will just create excel files..

See more in the help file

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top