Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

close all reports?

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
BG
Is there any function to close all reports when closing a report?
In the OnClose event of one of my open repots i have put the
following code:


Public Function CloseAllReports()
Dim i As Integer
For i = Reports.Count - 1 To 0 Step -1
DoCmd.Close acReport, Reports(i).Name
Next i
Beep
End Function
I do receive however the following mesage:

The action cant be carried out while a form or report is being opened.
I suppose my code is not the right one.
 
I'm not 100% sure on this, but I think the error is because you're trying to close the current report also. You could try something like this:

[tt]Public Function CloseAllReports()
Dim i As Integer
For i = Reports.Count - 1 To 0 Step -1
if Reports(i).Name <> me.name then
DoCmd.Close acReport, Reports(i).Name
end if
Next i
Beep
End Function[/tt]

Avoiding trying to close the current report thru the code, this should close the other reports, and let this report close &quot;by itself&quot;.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top