how to SQL a make table query from command button in access 2007.

PuddinPie

Registered User.
Local time
Today, 05:46
Joined
Sep 15, 2010
Messages
149
Ok. This one might be an intresting one.

What i'm trying to do is have a form.
In that form there is a combo box that lists all the queries in the database, let's call it cboX.
I also have a button, lets call it cmdExportToExcel.
What I am trying to attempt is when a query is selected from the dropdown and the button is clicked I want it to export that query to excel.
The way I was thinking of doing it is to run an SQL statement that builds a make table query on the fly with the query in the cboX as a variable so it knows which query to use and then have it export to excel the now made table but I can't seem to figure out what the SQL statement should look like or if there is a better way to accomplish this.

Thank you.
 
I don't see the point of the make table query. Why not just export the selected query with TransferSpreadsheet or OutputTo? Both will accept a named query as the source.
 
Ok. I understand that now but how do I get it to read what has been selected in the combo box and run and output to excel. I tryed forms!frmAvailQueries!cboAvailableQueries as the query name but it is not accepting it.
How do I use the combo box to provide the approprate query to export?
 
What exactly was your code, and what does "not accepting it" mean?
 
Sorry about the late resopnse. I did just create a module and did a function call for it.

Thank you
 

Users who are viewing this thread

Back
Top Bottom