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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply custom Toolbar to ALL reports on Startup in VB

Status
Not open for further replies.

nerdcore

MIS
Jan 23, 2003
26
0
0
Hi,

I would like to apply a custom toolbar to all reports when I open my database. Being that new reports are always being developed and management of these gets difficult, I would like to have a routine that automatically applies the toolbar to ALL reports upon startup. I know you can just set it by hand in the property sheet, or set it for a single report using VB, but I am looking for a solution that I could apply even if none of the report names were known at runtime. I have tried writing the VB using the AllReports object but it doesn't seem to work (or I just don't understand it). Has anyone done this before? Thanks!
 
Hey,

I couldn't figure it out without physically opening the reports, but this should work fine.

**********************************************

'
Public Function ApplyToolbar()
'
On Error Resume Next
'
Dim obj As AccessObject
Dim dbs As Object
'
Const myToolbar = "tlbrCFD"
'
Set dbs = Application.CurrentProject
'
For Each obj In dbs.AllReports
'
DoCmd.OpenReport obj.Name, acViewDesign, , , acHidden
Reports(obj.Name).Toolbar = myToolbar
DoCmd.Close acReport, obj.Name, acSaveYes
Next obj
'
Set dbs = Nothing
Set obj = Nothing
End Function

******************************************

Let me know if that helps,

flan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top