Determine if Report is open.

A

Andy

Hi;

Have created a Custom Menu Bar that is displayed when a Report is opened in
Print Preview. When the Report closes the standard Menu Bar is
re-displayed.

OnOpen
Reports.Application.MenuBar = "CustomMenu"
OnClose
Reports.Application.MenuBar = ""

All works correctly when one Report is open/closed. The obstacle to
overcome is when 2 or more Reports are opened. (The user can select more
than one Report to Preview.)

When the first Report is closed the CustomMenu is removed.

I know it is an If/Then statement. What is needed is the code to determine
if a Report is open in Preview.

Tried this, (modified from Help):
Dim obj As AccessObject, dbs As Object

Set dbs = Application.CurrentProject
' Search for open AccessObject objects in AllReports collection.
For Each obj In dbs.ALLREPORTS

If obj.IsLoaded = True Then
Reports.Application.MenuBar = "CustomMenu"
Else
Reports.Application.MenuBar = ""

End If
Next obj

Does anyone have an answer?

Andy
 
W

Wayne Morgan

Reports.Count will give you the number of open reports. If it is >0, then
there is a report open. This would, of course, include the report you are
making the check from, so you would need to check for >1.

Have you tried adding your toolbar to the Toolbar option of the report's
Properties sheet, Other tab?
 
A

Andy

Wayne;

Thank You for the reply.

Yes; did try the Toolbar option. Returns:
"The custom toolbar "CustomMenu" is the wrong type (menu, shortcut menu, or
toolbar) for the property it's being used in."

Although the CustomMenu is made in Access.

Will try Reports.Count >1

Andy
 
A

Andy

Wayne;

Thank You.

Andy


Andy said:
Wayne;

Thank You for the reply.

Yes; did try the Toolbar option. Returns:
"The custom toolbar "CustomMenu" is the wrong type (menu, shortcut menu, or
toolbar) for the property it's being used in."

Although the CustomMenu is made in Access.

Will try Reports.Count >1

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top