I'm saying that OutputTo is generating a different report than the report
specified in OpenReport, or at best a 2nd instance of the same report.
If all you want to do is Output it, then just Output it. No need to Open it
first. (The only exception that occurs to me is if you are Outputting
ReportB and ReportB needs a value from ReportA. That is the only thing that
would require ReportA to be open while Outputting.)
VB will not pause between OpenReport, OutputTo and Close unless you tell it
to (which you haven't). VBA will try to execute the next line of code as
soon as it can. When opening reports, form or queries, that can sometimes
mean before processing has finished (VBA has passed the instruction along to
Access but doesn't really know if its been fully completed, just that its a
legal instruction). As written, if your report opens a little slowly, there
is a chance VBA may try to close it before it has finished opening (hence
the error message) and if you want to close it that quickly, i simply
wonder: why bother opening it at all?
On the other hand:
>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
Is there any chance that ![ReportName] is getting changed or becomes invalid
while the report is being Opened or Output? (i.e., Is the form being changed
or closed?)
You might try assigning the value to a variable so you don't need to worry
about it:
strReportName = ![ReportName]
DoCmd.OpenReport strReportName, acViewPreview, "", "", acNormal
'...Output different report or a 2nd instance of strReportName here..
DoCmd.Close acReport, strReportName
For the record, the proper constant for the WindowMode argument of
OpenReport is acWindowNormal. No harm done since it has the same value as
acNormal: zero.

Signature
HTH,
George
> George,
> Thanks for the reply. The reason I'm wanting to close it is because the
[quoted text clipped - 27 lines]
>>> DoCmd.Close acReport, ![ReportName] ' This line causes the issue
>>> End Select
FlBrent - 09 Apr 2008 22:32 GMT
George,
I'll have to offer up a big Homer Simpson 'Doh!!!!'. Thanks man. It's
amazing how many times you look at something right in front of you face and
don't see it. That explains everything. I left the OpenReport code in there
(from a previous task). I removed it and it's all good. Thank you so much
for your help!!!
Brent
>I'm saying that OutputTo is generating a different report than the report
>specified in OpenReport, or at best a 2nd instance of the same report.
[quoted text clipped - 40 lines]
>>>> DoCmd.Close acReport, ![ReportName] ' This line causes the issue
>>>> End Select