set menubar and toolbar for all reports via code

M

microb0x

Does anyone know how to enumerate through the AllReports collection to
set a custom menubar and toolbar for each report in the collection?

I can set the menubar and toolbar when a report is open, but I need to
be able to set these whether a report is open or not.

I need to set the menu/tool bars for each report during the launch of
the startup form. There are 60 some reports in the application, and
ever growing, and I'd rather not have to set each one individually via
its property sheet
 
B

Brendan Reynolds

microb0x said:
Does anyone know how to enumerate through the AllReports collection to
set a custom menubar and toolbar for each report in the collection?

I can set the menubar and toolbar when a report is open, but I need to
be able to set these whether a report is open or not.

I need to set the menu/tool bars for each report during the launch of
the startup form. There are 60 some reports in the application, and
ever growing, and I'd rather not have to set each one individually via
its property sheet


You need to open the reports in design view, but you don't have to do it
manually, you can automate it ...

Public Sub SetRepProp()

Dim aob As AccessObject
Dim rpt As Report

For Each aob In CurrentProject.AllReports
DoCmd.OpenReport aob.Name, acViewDesign, , , acHidden
Set rpt = Reports(aob.Name)
rpt.MenuBar = "MyMenuBar"
rpt.ShortcutMenuBar = "MyShortCutMenuBar"
rpt.Toolbar = "MyToolbar"
DoCmd.Close acReport, aob.Name, acSaveYes
Next aob

Debug.Print "Finished!"

End Sub
 

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