Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

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?

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
ASKER CERTIFIED SOLUTION
Avatar of Jim P.
Jim P.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeffrey Coachman
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