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

Using VB to Export an Access Query to Excel 1

Status
Not open for further replies.

matzos

Programmer
Aug 22, 2001
38
0
0
US
Well, the title pretty much says it all...

I have to write up a program that will automatically run and export an Access query on a weekly basis. I have all of the programming necessary to initiate the timing automation but I can't seem to figure out how to control the Access mdb and export the query.

Any help you be GREATLY appreciated!

Kevin
 
You will have to have a vb program that will connect to access via DAO/ADO. The run the query to pull into a recordset in vb then you can export to Excel. MSDN has code on how to export to excel at that point. Or I can post it...
 
Set a reference in your code to the Microsoft Access x.x Object Library
Code:
Dim accApp As Access.Application

Set accApp = New Access.Application

accApp.OpenCurrentDatabase "database path"
accApp.DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "TableName", "excel file name"

accApp.CloseCurrentDatabase
Set accApp = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top