[AccessD] Controlling Custom Toolbars

Stuart McLachlan stuart at lexacorp.com.pg
Thu Sep 11 01:07:03 CDT 2008


If you ONLY want the custom toolbar (ie you don't want the default Form toolbar as well),
just set the Toolbar property in the Forms Property Sheet-Other tab.

Otherwise use

DoCmd.ShowToolbar "IT PMO Financial Control Tool", acToolbarYes
and
DoCmd.ShowToolbar "IT PMO Financial Control Tool", acToolbarNo

to display/hide it.


On 11 Sep 2008 at 15:48, Darryl Collins wrote:

> 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.
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com

-- 
Stuart Mclachlan





More information about the AccessD mailing list