I have a couple of buttons on a toolbar that I want to be either not visible or visible depending on options available to the user.
They are the Commit/Rollback (Save/Undo) buttons. When a record is loaded they are not visible until the user changes a field at which point they become visible. These buttons were previously not on the toolbar but at the bottom of the window and I just used the visible property. There is no corresponding visibility property on a toolbutton… So I wrote the following method. It works fine except I would like to make it a global method in a global module so that it doesn’t have to be repeated in each window. The problem is, when I put it in the global module, the tbNavigate1 toolbar isn’t available. I don’t especially want to make it public because the toolbar is named the same in every window.
So does anyone have a solution? thanks so much.
[code]Private Sub HideShowToolbarButtons(sAction As String)
if sAction = “Show” then
tbNavigate1.tiSave.icon = save40
tbNavigate1.tiSave.Caption = “Save”
tbNavigate1.tiRollback.icon = Trash32
tbNavigate1.tiRollback.Caption = “Undo”
else
tbNavigate1.tiSave.icon = nil
tbNavigate1.tiSave.Caption = “”
tbNavigate1.tiRollback.icon = nil
tbNavigate1.tiRollback.Caption = “”
end if
and that will leave a button that cant be seen but is still pushable
there is no “visible” or not for a tool bar item
the button either exists or doesn’t (its just the way they work)
i’d add and remove the items
in your global module make your method be something like
HideShowToolbarButtons(whichToolbar as Toolbar, sAction As String)
if sAction = "Show" then
whichToolbar.tiSave.icon = save40
whichToolbar.tiSave.Caption = "Save"
whichToolbar.tiRollback.icon = Trash32
whichToolbar.tiRollback.Caption = "Undo"
else
whichToolbar.tiSave.icon = nil
whichToolbar.tiSave.Caption = ""
whichToolbar.tiRollback.icon = nil
whichToolbar.tiRollback.Caption = ""
end if
End Sub
Tim, I first tried the enable/disable property, but there is VERY LITTLE difference in the way a disabled button looks from the way an enabled one does. Much less difference that in other controls.