473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

export queries to excel?

AccessIdiot
493 256MB
Hi all,

I have a bunch of queries (about 40) that right now I am exporting one by one to excel. Is there a way to do a mass export? With the "save formatted" box checked? I don't want to have this as a button on a form - I just want to export everything in the Queries object in the database.

Thanks for any help!
Aug 8 '07 #1
5 1693
ADezii
8,834 Expert 8TB
Hi all,

I have a bunch of queries (about 40) that right now I am exporting one by one to excel. Is there a way to do a mass export? With the "save formatted" box checked? I don't want to have this as a button on a form - I just want to export everything in the Queries object in the database.

Thanks for any help!
The following code will Export all but the Temporary Queries ("~*") to an Excel 9.0 format in the C:\Test Directory. The Spreadsheets will have the Base Query Name with the .xls extension appended. Is this what you are looking for?
Expand|Select|Wrap|Line Numbers
  1. Dim qdf As DAO.QueryDef
  2.  
  3. For Each qdf In CurrentDb.QueryDefs
  4.   'Filter out Temporary Querys
  5.   If Left$(qdf.Name, 1) <> "~" Then
  6.     DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, qdf.Name, "C:\Test\" & qdf.Name & ".xls", True
  7.   End If
  8. Next
Aug 9 '07 #2
AccessIdiot
493 256MB
The following code will Export all but the Temporary Queries ("~*") to an Excel 9.0 format in the C:\Test Directory. The Spreadsheets will have the Base Query Name with the .xls extension appended. Is this what you are looking for?
Expand|Select|Wrap|Line Numbers
  1. Dim qdf As DAO.QueryDef
  2.  
  3. For Each qdf In CurrentDb.QueryDefs
  4.   'Filter out Temporary Querys
  5.   If Left$(qdf.Name, 1) <> "~" Then
  6.     DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, qdf.Name, "C:\Test\" & qdf.Name & ".xls", True
  7.   End If
  8. Next
Yes, but I do have a couple of questions - where do you typically put this code? How do you call it? Also, when I export one by one there is a check box for "save format" which will (for example) input "true" or "false" instead of "1" or "0" in the excel table. Can I accomplish this in the above code?

I was sort of hoping there was an "export all queries" choice in a menu within Access somewhere but I guess this doesn't exist? Oh I'm using Access 2003 by the way.

Thanks for your help!
Aug 9 '07 #3
ADezii
8,834 Expert 8TB
Yes, but I do have a couple of questions - where do you typically put this code? How do you call it? Also, when I export one by one there is a check box for "save format" which will (for example) input "true" or "false" instead of "1" or "0" in the excel table. Can I accomplish this in the above code?

I was sort of hoping there was an "export all queries" choice in a menu within Access somewhere but I guess this doesn't exist? Oh I'm using Access 2003 by the way.

Thanks for your help!
  1. You can place this clode in the Click() Event of a Command Button.
  2. You call the code by just clicking on the above-mentioned Command Button.
  3. The TransferSpreadsheet Method has no provisions for maintaining or ignoring formatting options.
  4. There is no Menu witin Access where you can 'Export All Queries'.
Aug 9 '07 #4
AccessIdiot
493 256MB
4. That's what I was afraid of. :( Hint hint MS!!!

Thanks for answering my questions!
Aug 9 '07 #5
ADezii
8,834 Expert 8TB
4. That's what I was afraid of. :( Hint hint MS!!!

Thanks for answering my questions!
You are quite welcome.
Aug 9 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Anthony Cuttitta Jr. | last post by:
I'm working on some procedures where Access queries are exported to Excel, and then later on, those same workbooks are openned, and I need to target a specific original sheet. Sometimes there will...
8
by: Taffman | last post by:
I've searched this goup for an answer to this, there are many discussions that come close but non that I can find that actually addresses this particular problem. I'm exporting queries to Excel....
0
by: JayDawg | last post by:
If anyone is willing to provide some consulting pro-bono, or for a very small charge I would really love the asistance. If anyone can fix my problem here online that would be even better. Here...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
0
by: sandervanee | last post by:
Hello, I am trying to export several Access 2003 select queries to Excel 2003 using an Access macro. I'm using the macro command "TransferSpreadsheet" to export the queries. This going quit well,...
4
by: Chris Gilpin | last post by:
Hey everybody. I have Access set up using VBA to run a bunch of queries automatically, and then export the results into Excel. The only problem is, I want each query to be exported to the same...
1
by: Pauline | last post by:
Dear all, I have an enormous database (Access 2003) containing sales information, and an Excel tool to enable end users to do planning and forecasting. Untill now I would create several queries,...
3
by: jmarcrum | last post by:
I want to export a report (that contains two separate queries, 1. Current year data, and 2. split-year data) from access into excel, but everytime I run my code and export the data to excel, it looks...
2
by: Marisol2 | last post by:
I have some queries in Access 2003 db that I have setup to display as pivots. I can go into design pivot table view and click on and then click on Export to Office MicroSoft Excel. The problem is I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.