Exporting question

Evenflow

Registered User.
Local time
Yesterday, 19:42
Joined
Apr 13, 2005
Messages
22
Hello. I've searched around the board and help files and couldn't find a straight answer for this. I have 7 or 8 different queries. Is there a way to export Query 1 to Sheet 1 of my excel workbook, then Query 2 to sheet 2 of the workbook, and so on? Thanks.
 
The only way I know how to do this is via Automation (VBA) or to seperate XLS files and an Excel macro to import them all into different sheets.
 
I agree with FoFa.

You need to do a VBA routine in order to be able to specify an export other than to the first worksheet of the workbook.
 
In your Export module, make recorsets for each query
e.g rs1 for qry1, rs2 for qry2. Create the excel object.
Make different Loops using the different recordsets. For each loop, reference the objects sheets to that qry.

i.e:
Code:
For i = 0 To rs1.Fields.Count - 1
     ExcelApplication.sheets("Sheet1").cells(ex_r, i + 1)= rs1.Fields(i).Value
Next

For i = 0 To rs2.Fields.Count - 1
     ExcelApplication.sheets("Sheet2").cells(ex_r, i + 1)= rs2.Fields(i).Value
Next

Hope it helps.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom