export access query to excel

S

sun

Hello!

I wish to export a query to excel via "TransferSpreadsheet":

DoCmd.TransferSpreadsheet acExport, 8, "Queryname", "H:
\Office2000\Access\Test2.xls", True, "

With this code I could only export tables, not queries. The error message
says it can't find any objects with the name "Queryname". Can anyone tell me
how to modify the code in order to search for queries?

Thanks!!
 
F

fredg

Hello!

I wish to export a query to excel via "TransferSpreadsheet":

DoCmd.TransferSpreadsheet acExport, 8, "Queryname", "H:
\Office2000\Access\Test2.xls", True, "

With this code I could only export tables, not queries. The error message
says it can't find any objects with the name "Queryname". Can anyone tell me
how to modify the code in order to search for queries?

Thanks!!

This works for me.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryExportYear", "C:\My Household\YearlyGraphs.xls",True

You did change "Queryname" to the actual name of your query didn't
you? Are you sure you have the name of the query spelled correctly?

You also have an extra quote symbol stuck at the end of your code.
If there is no argument after True, leave it blank and omit the final
comma.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top