Solved

export multiple queries to 1 excel spreadsheet

Posted on 2004-09-28
5
929 Views
Last Modified: 2008-03-03
I have 5 queries which i need to export into 1 excel spreadsheet. each query will have its own tab in excel.

class anyone?

don't know where to get started. queries are are already built.

all help is appreciated.
0
Comment
Question by:lallentx
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
pique_tech earned 250 total points
ID: 12174956
Repeated use of DoCmd.TransferSpreadsheet to the same Excel destination file will add each query on a tab with the same name as the query.

i.e.,
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Product", "c:\test.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "ProductCategory", "c:\test.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "ProductGroup", "c:\test.xls", True

produced a spreadsheet at c:\ called test.xls with three tabs, one called Product, one called ProductCategory, and the last called ProductGroup

You should delete the Excel file before repeating or you'll (potentially) get unexpected behavior.

Hope this helps.
0
 
LVL 12

Expert Comment

by:pique_tech
ID: 12174968
(That assumes that you're using MS Access...if not, then I'm pretty sure my method won't work.)
0
 
LVL 4

Expert Comment

by:ndegioia
ID: 12179626
Form what I can understand Execl can read sql staments.  If you are using a sql or access database you can write a stored proceedure to execute multiple queries.  Here is the sytax

create proceedure Myproceedure
as
Select yourColumn
Form YourTable
Where YourConditions
go
Select yourColumn
Form YourTable
Where YourConditions
go

...and so on


Then all you have to do in Execl of any other client side app is run

Exec MyProceedure
go


Note you must be connected to sql or save the stored prceedure as a Macro.

Hope this helps;)
0
 

Author Comment

by:lallentx
ID: 12179701
pique tech, I will try your approach first, and Yes! it is MS Access what I'm using.
I'll keep y'all posted.
0
 

Author Comment

by:lallentx
ID: 12183568
Pike tech,
you are a genius in my book!

it worked!

thanks so so much.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Query assistance 16 46
error doing substr 3 37
error starting form builder in 11g 2 27
Cannot connect to SQL express 2008 R2 installed on Server 2016 5 21
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Creating and Managing Databases with phpMyAdmin in cPanel.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question