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

export to excel from a form

Status
Not open for further replies.

AcornD

IS-IT--Management
May 22, 2002
37
GB
i have a form which we use to filter data then once the data has been filtered we want to export the filtered data into a excel spreadsheet by clicking on a button but cannot work out how to acheive this.
 
Easy...

In your button you need to add the command

Docmd.OutputTo

For example,

DoCmd.OutputTo acOutputQuery, "TestResults", acFormatXLS, "C:\MyFile.xls", 1

This will run my query called TestResults and make a spreadsheet from the results, the 1 at the end makes it so that it then opens excel and runs the spreadsheet for me as well.

DoCmd.OutputTo acOutputTable, "Tests", acFormatXLS, "C:\MyTable.xls", 1

This would open the table "Tests" and just export it all to an Excel sheet called MyTable.xls and open it for me.






Hope this helps!

Regards

BuilderSpec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top