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

Query to export data to excel 2

Status
Not open for further replies.

FeS2

Technical User
Aug 16, 2002
82
US
Is there a way to use a query to retrieve data from a table and then export it straight to Excel 2000 spreadsheet. It will have to create the spreadsheet when the query is run. Thanks in advance.
 
Hi

see docmd.transferspreadsheet in help, with this command tou can import or export an excel spread sheet Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Try this line of code


DoCmd.OutputTo ouputQuery, "Your Query", "MicrosoftExcel(*.xls)", "C:\Your File.xls", True, ""

Hope it helps
 
Thank you. The code worked great!
 
And by this code you can dend the table by e-mail, i think i got this code from KenReay !!


DoCmd.SendObject acSendTable, "TblName", acFormatXLS, "eliahu@cuok.co.il", "solutions@cuok.co.il", , _
"Current Spreadsheet of Biochemistry", , False


CUOK
 
As suggested by Ken the cmd.transferspreadsheet is an alternative command that can be used, e.g.

DoCmd.TransferSpreadsheet acExport, , "Queryname", "c:\Your Filename", True, ""


No need for the file extention in the file name as this command has defaulted to Excel version 8.

Works for me!

JR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top