Solved

Exporting from Access query to Excel using DoCmd.OutputTo acOutputQuery

Posted on 2004-04-15
3
2,020 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

863 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

20 Experts available now in Live!

Get 1:1 Help Now