Solved

How to prevent the "Runtime error 2304: Microsoft Office Access can't save output to the specificed file" when export 35,000 records from Stored Procedure in Access 2003 application using Excel 2003?

Posted on 2013-05-09
2
771 Views
Last Modified: 2013-05-16
How to avoid the Runtime error 2304:  Microsof Office Access can't save output data to the specified file in an Access 2003 application using Excel 2003? The application has
35,000 records in a result set from a stored procedure. I am attempting to write the records to an Excel file. The reason I use the Access report rptDtlBranchAll is to create subtotal and total records for the 35,000 detail records.

    With com
       .CommandType = adCmdStoredProc
       .CommandText = "dbo.procDetailBranchAll"
       .Parameters.Append .CreateParameter("@Branch", adVarChar, adParamInput, 4, strBranch)
        Set .ActiveConnection = CurrentProject.Connection
       .Execute
    End With
   
    ExportedFile = CurrentProject.Path & "\Reports\DTLBRANCHALL" & "_" & intYearSP & "_" & Format(Now, "mmddhhnnss") & ".XLS"
       
    DoCmd.OutputTo acOutputReport, "rptDtlBranchAll", 8, ExportedFile
0
Comment
Question by:zimmer9
[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
2 Comments
 
LVL 38

Accepted Solution

by:
Jim P. earned 500 total points
ID: 39158765
Are you sure that path exists?  And the user has write permissions?

Try adding this code ahead of the export:

If Dir(CurrentProject.Path & "\Reports\") <> "." Then
      MKDir CurrentProject.Path & "\Reports"
End IF

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39163538
I think Jim has your answer here...

Can you post the entire code please?

We cannot see where you are loading intYearSP, nor can we see your declarations...

Also, are you quite sure that the format: "8" is valid?
I only ever use the string values, and it woks fine:

acFormatHTML
acFormatRTF
acFormatSNP
acFormatTXT
acFormatXLS
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

749 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