?
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
?
782 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

764 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