Problem Outputting to Excel

poet1234

Registered User.
Local time
Today, 06:28
Joined
Oct 7, 2004
Messages
46
I am trying to output a report to Excel with the following code:

Private Sub cmdExcelExec_Click()
On Error GoTo Err_Handler

Dim strReport as String
strReport = rpt_TransRegister

Docmd.OutputTo acOutputReport, strReport, acFormatXLS, "expenditure_report.xls", True

Exit_cmdExcelExec_Click:
Exit Sub

Err_Handler:
Msgbox Err.Number & " - " & Err.Description & vbCr & "Procedure: " & Err.Sourse, vbCritical + vbOKOnly, "Error Encountered"
Resume Exit_cmdExcelExec_Click

End Sub

I am receiving the following error:

"2196 - Budget Application can't retrieve the value of this property. Procedure: MSAccess."

I searched around the forum and didn't come up with anything useful on this error. I also checked the MS Knowledge Base and came up with nothing.

Thanks in advance... :confused:
 
You posted

Docmd.OutputTo acOutputReport, strReport, acFormatXLS, "expenditure_report.xls", True

I don't think that you can send a report to an except file.

Of course, you can transfer the recordsource of that report via

docmd.transferdatabase etc.

docmd.transfersdatabase allows for an acReport argument, but I've never used it.

I use the docmd.transferdatabase regularly.
 
Hi. I'm confused, as I don't know what an "except" file is. I am trying to output to an MS Excel file, and I know you can export reports because I have done it many times in the past. Thanks...
 
Try pasting this code;

On Error GoTo Err_Command11_Click

Dim stDocName As String

stDocName = "YourReportName"
DoCmd.OutputTo acReport, stDocName

Exit_Command11_Click:
Exit Sub

Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click


hth,

Michael
 
Spelling mistake I think;

Shouldn't Err.Sourse be Err.Source?

Quite funny when you think about it... your error trapping caused the error ;-)
 

Users who are viewing this thread

Back
Top Bottom