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

TAKE QUERY RESULTS TO EXCEL

Status
Not open for further replies.

Kevsim

Instructor
Apr 18, 2000
385
AU
I have a query that is set to run with Enter first date, Enter last date. What I want to further do is have added code so when the query runs after the date selection, it will take the query to Excel for analysing. I am not sure how to do this and would appreciate some advise.
kevsim
 
Look up DoCmd.TransferSpreadsheet. The souce for an export can be either a table or a query.

DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel97, YourQueryName, YourExcelName

Good Luck!
 
SBendBuckeye, Thank you for the info. However, I am having problems when I run the code, it reaches TransferSpreadsheet (Lookup DoCmd.TransferSpreadsheet), I receive the error message, Expected Function or variable.
Should I stop the first line running, I receive the error message when it reaches my query name, Variable not defined.

Lookup DoCmd.TransferSpreadsheet 'The source for an export can be either a table or a query.
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel97, Q_FinalData, WagesTemplate.xls

Could you please advise what I am doing wrong.
Kevsim
 
Sorry, my post was for Excel97. What version are you running? If you type in DoCmd.TransferSpreadsheet and then hit the space bar it should prompt you with Intellisense. Try just letting it default the Excel type (eg just get rid of the acSpreadSheetTypeExel97)

Good LucK!
 
Do you have a stored query? You might try using the Pivot Table Wizard with a couple textboxes added to the form it makes for your start and end dates input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top