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

Creating a form to run a Query And export/save as an Excel

Status
Not open for further replies.

DouglasLB

Technical User
Jun 18, 2001
10
0
0
US
I have a query that I currently run/export as an excel workbook that asks for a date range, and a few other criteria.

I would like to create a form that i can enter the criteria (ie date range and some other things. I have made one for running a report but how do I get it to run the query. And I also want to have a field to enter what i want the excelworkbook that will be created named.

Do I have to make a module? Macro? or do the commands go into the properties window for the command button on the form?

I did recieve some help on my original question, but I dont know enough about Access to make it work.
thread702-153459 would I go about this and what would the macro look like?

Thanks,
Douglas
 
First, you need to create an update query which will create a update a table and a delete query which will delete all information in that table. Then, you need to set the query criteria to look at the form.

Create a command button on the form that ties into a Macro. In the macro, put the openquery action in with the deletequeryname;
the openquery code in with the "runqueryname";
and then the transferspreadsheet action in with the path & filename of the .xls sheet you are trying to export the data to.

Basically what the macro will do is delete any old information from the table, place the new information in the table, and then transfer the data to the *.xls file you specified.

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top