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!

Form to Give Name to An Exported Query 1

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 same information ( i think i know how to do that), but I also want to have a field to enter what i want the excelworkbook that will be created named.

How would I go about this and what would the macro look like?

Thanks,
Douglas
 
On the form where you enter criteria add textbox named txtFileName and a button cmdExport.

Then in the OnClick event procedure insert the following code:

Private Sub cmdExport_OnClick()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "NameOfYourQuery", Path & txtFileName & ".xls"
End Sub

You replace word Path with the path, where you want the file to be created, for example "C:\My Documents"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top