[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
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
Medium Priority
?
787 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 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

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.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

650 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