Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Exporting from Access query to Excel using DoCmd.OutputTo acOutputQuery

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

618 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