F
FlBrent
Hi,
I've written a report scheduling tool based on a Form Timer_Event. I
have built a 'report schedule' table which contains many fields I require to
run the reports based on the timer. Anyway, I create a recordset, based on
the reports in the schedule table, and run the reports when it's time for
them to run. I can run the report just fine, based on the report name I pull
from the report schedule table. However, the report runs in a preview window
and I want to close the window after I print it or send it to a file server.
But.. when I attempt to close the report (in the preview window), I get an
"Object Invalid and no longer set" error message. I don't know if it's got
something to do with me looping through a recordset or not, but it doesn't
work for me. Case "03" causes the issue. Please help if you can. Thanks.
Here's a snippet of code:
Select Case ![SchOutput_Type]
Case Is = "00"
MsgBox "Output to Local Printer"
DoCmd.OpenReport ![ReportName], acViewNormal ' to print the report to the
local printer
'DoCmd.OpenReport ![ReportName], acViewPreview, "", "", acNormal ' to view
the report (for testing)
Case Is = "01"
MsgBox "Output to Other Printer"
Case Is = "02"
MsgBox "Output to Email"
Case Is = "03"
MsgBox "Output to File Directory"
DoCmd.OpenReport ![ReportName], acViewPreview, "", "", acNormal
DoCmd.OutputTo acReport, "Del_Notices", "MicrosoftExcelBiff8(*.xls)", !
[OutputPath], False, "", 0
MsgBox "File Saved Successfully"
DoCmd.Close acReport, ![ReportName] ' This line causes the issue
End Select
I've written a report scheduling tool based on a Form Timer_Event. I
have built a 'report schedule' table which contains many fields I require to
run the reports based on the timer. Anyway, I create a recordset, based on
the reports in the schedule table, and run the reports when it's time for
them to run. I can run the report just fine, based on the report name I pull
from the report schedule table. However, the report runs in a preview window
and I want to close the window after I print it or send it to a file server.
But.. when I attempt to close the report (in the preview window), I get an
"Object Invalid and no longer set" error message. I don't know if it's got
something to do with me looping through a recordset or not, but it doesn't
work for me. Case "03" causes the issue. Please help if you can. Thanks.
Here's a snippet of code:
Select Case ![SchOutput_Type]
Case Is = "00"
MsgBox "Output to Local Printer"
DoCmd.OpenReport ![ReportName], acViewNormal ' to print the report to the
local printer
'DoCmd.OpenReport ![ReportName], acViewPreview, "", "", acNormal ' to view
the report (for testing)
Case Is = "01"
MsgBox "Output to Other Printer"
Case Is = "02"
MsgBox "Output to Email"
Case Is = "03"
MsgBox "Output to File Directory"
DoCmd.OpenReport ![ReportName], acViewPreview, "", "", acNormal
DoCmd.OutputTo acReport, "Del_Notices", "MicrosoftExcelBiff8(*.xls)", !
[OutputPath], False, "", 0
MsgBox "File Saved Successfully"
DoCmd.Close acReport, ![ReportName] ' This line causes the issue
End Select