geeta_m9
asked on
Creating a command to export the results of a query to a spreadsheet
I would like to create a command so that when the user clicks on a button, the results of a query will be exported to an Excel spreadsheet. I know how to do this for a table, but would I do it for a query? The name of my query is "qJoinThreeTables".
ASKER
I tried that, but it doesn't seem to work.
ASKER
This is the command I used:
DoCmd.TransferSpreadsheet acExport, 10, "qJoinThreeTables", "c:\Users\Documents\Applic ationsStat ementsRevi ews.xlsx", True
Perhaps I need to execute the query first.
DoCmd.TransferSpreadsheet acExport, 10, "qJoinThreeTables", "c:\Users\Documents\Applic
Perhaps I need to execute the query first.
ASKER
I modified the command slightly and now it seems to work. Not sure why it didn't work before.
DoCmd.TransferSpreadsheet acExport, , "qJoinThreeTables", "c:\Users\Documents\Applic ationsStat ementsRevi ews.xlsx", False
DoCmd.TransferSpreadsheet acExport, , "qJoinThreeTables", "c:\Users\Documents\Applic
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
The 10 was Office 2002 (if I am not mistaken), which is why you could not create a xlsx file. They were introducted in Office 2007 (Office 12). Office 11 did have filters to manage them, but don't think they went back any earlier
ASKER
Thanks!
Kelvin