Solved

Exporting from Access query to Excel using DoCmd.OutputTo acOutputQuery

Posted on 2004-04-15
3
1,985 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now