View Full Version : Problem Outputting to Excel


poet1234
12-21-2004, 09:38 AM
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:

llkhoutx
12-21-2004, 08:29 PM
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.

poet1234
12-22-2004, 06:57 AM
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...

Ukraine82
12-22-2004, 07:13 AM
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

llkhoutx
12-22-2004, 07:16 AM
Fat fingers. I obviously meant Excel file.

reclusivemonkey
12-24-2004, 02:52 AM
Spelling mistake I think;

Shouldn't Err.Sourse be Err.Source?

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