By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,290 Members | 2,319 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,290 IT Pros & Developers. It's quick & easy.

delete all records ?

P: n/a
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.
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The problem is probably with the report whose Close event is currently
executing. You want to close all the *other* reports.

Try:
If Reports(i).Name <> Me.Name Then
doCmd.Close acReport, Reports(i).Name
End If

If you need to handle multiple instances of the same report (same name), you
may need to use the hWnd instead of the name.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Johm" <ke**@abv.bg> wrote in message
news:24**************************@posting.google.c om...
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.

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.