PDA

View Full Version : Is it possible to run a query that automatically populates in excel?



wedd
07-26-2011, 03:21 AM
Is it possible to run a query that automatically populates in excel? Im using Excel and Access 2010 and what I want to achieve is when a particular query is run the results are populated in a blank spreadsheet to. Is that possible with the click of a run button? if so, what steps can be done to do this? I have limited vba skills but I am competent with access and excel...I'm using excel to do a comparative analysis of statistics and the data is in access. Thanks for your clever suggestions? :friends:


Also if you have an example how the data is displayed in excel that would be very useful. If you have an example on how to run a routine to do this operation. The fields I am exporting are Agent_Result (text field), Confirmation sent (Date field), Date sent (date field) and Date (Date field). These fields are in 10 different databases and have to be updated everyday...I'm not sure whether to link all the databases then create a routine to auto-populate the results on a blank spreadsheet...

Thanks guys for your suggestions... :-)

This is the code I have been using:

Dim oAccess As access.Application
Set oAccess = New access.Application
oAccess.OpenCurrentDatabase "c:\Database"
oAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "query", "C:\Spreadsheet.xls", True
oAccess.Quit

hansup
07-26-2011, 09:45 AM
This is the code I have been using:

Dim oAccess As access.Application
Set oAccess = New access.Application
oAccess.OpenCurrentDatabase "c:\Database"
oAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "query", "C:\Spreadsheet.xls", True
oAccess.Quit

Apparently that code doesn't do everything you want, or you wouldn't be asking a question. (Right?) So what doesn't it do that you need done?

Does that code create error messages? If so, what are they?