Solved

Exporting from Access query to Excel using DoCmd.OutputTo acOutputQuery

Posted on 2004-04-15
3
2,301 Views
Last Modified: 2007-12-19
I use the line:

DoCmd.OutputTo acOutputQuery, "qryReportDataForExcelOutput", acFormatXLS, strOutputFileEXCEL, False

which works fine.... except when I have more than 16K records to export.  When I have too many records Access is unable to successfully create the file. I can step into the above line and see the Excel file in Windows Explorer while Access is exporting, but after a delay of a minute or so the file disappears!

If I manually export the query to Excel it works fine, even with more than 16K records.

I have reproduced this behavior on two PCs running XP Pro and Office XP.

So, how can I successfully export this query to Excel with more than 16K records, IN CODE rather than manually?
0
Comment
Question by:wlevy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 10835336
Hello wlevy,

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qryReportDataForExcelOutput", "C:\myfilename.xls", True

If you don't want fieldnames change True to False.

Pete
0
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 10835420
The problem is that OutputTo creates an Excel 4.0 file (I think that's the right version number) which can only have 16k rows. As Peter says, TransferSpreadhseet is where you need to look. It lets you choose the Excel file format, and so you will be able to export up to 65k rows.
0
 

Author Comment

by:wlevy
ID: 10835840
Thanks guys, and enjoy the points Peter.  I figured it was something like this but didn't know exactly how to resolve it!

- W
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

719 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