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

Is it possible to transfer the cont

Status
Not open for further replies.

mitch1660

Programmer
Jul 24, 2001
2
CA
Is it possible to transfer the contents of a SELECT query from an access table to an excel sheet in one shot(by programming in VBA) instead of browsing the recordset one by one. Just like an ODBC query but in a simple SQL query.
 

Export the query result to Excel. You can do this manually, in a Macro (TransferSpreadsheet action) or in VBA (docmd.transferspreadheet method).

VBA syntax:
DoCmd.TransferSpreadsheet [transfertype][, spreadsheettype], tablename, filename[, hasfieldnames][, range]

VBA example:
DoCmd.TransferSpreadsheet acExport, 8, "qrySales", "c:\export\excel\Sales.xls" Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it if you have time.
 
Method 1. Create a macro and save it.

Method 2:

DoCmd.TransferSpreadsheet acExport, 5, "tbl-Repair Tech Output/Labor Analysis", "ExcelOutput", True, ""

acExport means Export
5 means the spreadsheet version
"tbl-Repair....." is the table. (Could also be a query)
"ExcelOuput" is the name of the new file
True means you want the spreadsheet to have column headings
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top