[AccessD] Controlling Custom Toolbars

Darryl Collins Darryl.Collins at coles.com.au
Thu Sep 11 00:48:50 CDT 2008


Hi Folks,

When I code in Excel I use custom toolbars a lot and they are dead easy to control.  Often each set will have it own toolbar that has tools specific to its purpose and these are turned off and off using worksheet activate/deactive.

In this Access beastie I am building I have made up a nice little custom toolbar, but I only want it to be available on when certain forms are active.  Struggling to get the syntax right on making the toolbar appear / disappear.

Here is what I have go so far (which works - it is just too darn untidy - there has to be a better way).

'========WHAT I HAVE (which works) =======================
Sub RemoveDataEditToolbar()

Dim mtb As Variant ' <-- Don't like using variant, but it is the only thing I can find that works.
Dim strToolbar As String

strToolbar = "IT PMO Financial Control Tool"

For Each mtb In CommandBars ' <-- Don't like having to loop. Just want to set this to true or false
    If mtb.Name = strToolbar Then
        mtb.Visible = False
        MsgBox mtb.Name & " Hidden"
    End If
Next mtb
End Sub
'===============================================

'========WHAT I WANT (which doesn't) ===================
Sub RemoveDataEditToolbar()

Dim mtb As Access.CommandBar
Dim strToolbar As String

strToolbar = "IT PMO Financial Control Tool"
Set mtb = Access.CommandBar.Name(strToolbar)
mtb.Visible = False

set mtb = nothing
End Sub
'===============================================


Any ideas?

cheers
Darryl

This email and any attachments may contain privileged and confidential information
and are intended for the named addressee only. If you have received this e-mail in
error, please notify the sender and delete this e-mail immediately. Any
confidentiality, privilege or copyright is not waived or lost because this e-mail
has been sent to you in error. It is your responsibility to check this e-mail and
any attachments for viruses.  No warranty is made that this material is free from
computer virus or any other defect or error.  Any loss/damage incurred by using this
material is not the sender's responsibility.  The sender's entire liability will be
limited to resupplying the material.





More information about the AccessD mailing list