Export Queries at Run Time

J

JimS

I have a form that presents a number of reports for the users. Each report
has an associated query (or we can assume that anyway....) I want to present
the option of "export to Excel" for each (or at least many...) of the
reports. If I were in the interactive system, I'd do a FILE->EXPORT for the
query. How can I do this at runtime?
 
R

Roger Carlson

You can use the TransferSpreadsheet method to export a table or query to
Excel in code. Create a Macro that uses the TransferSpreadsheet action,
then save it as VB code. That will give you the basic form of the command.
But because it is VBA, you will be able to add parameters and error trapping
and such.

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "ExportToExcel.mdb" which illustrates this.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Top