?
Solved

Exporting from Access query to Excel using DoCmd.OutputTo acOutputQuery

Posted on 2004-04-15
3
Medium Priority
?
2,400 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 1000 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

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.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

777 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