Darryl Collins
Darryl.Collins at coles.com.au
Thu Sep 11 23:58:40 CDT 2008
Ok... Got these pesky Access toolbars to work as expected - *phew* spend much of today on this. You know, it is a complete b at stard trying to find the Toolbar FaceID's that work in Access. Dead easy in Excel to get that info - anyway, a bit of hacking Excel VBA and trial and error with ID's in Access and I have this working well now. Thanks for everyones help. Love the toolbars though, much neater than making custom buttons on each form. Definately need to set a reference to the Microsoft Office Object Libarary! '========================================================= Option Compare Database Option Explicit Sub CreateNavigationToolbar() Dim cmdbarNavigation As CommandBar ' Destroy the existing toolbar if exists On Error Resume Next CommandBars("Navigation Toolbar").Delete On Error GoTo 0 ' Create the toolbar Set cmdbarNavigation = CommandBars.Add(Name:="Navigation Toolbar", _ Position:=msoBarBottom, _ Temporary:=True) With cmdbarNavigation .Controls.Add Type:=msoControlButton, Id:=1786 '1 Close .Controls.Add Type:=msoControlButton, Id:=154 '2 GotoFirst .Controls.Add Type:=msoControlButton, Id:=155 '3 GotoPrev .Controls.Add Type:=msoControlButton, Id:=156 '4 GotoNext .Controls.Add Type:=msoControlButton, Id:=157 '5 GotoLast .Controls.Add Type:=msoControlButton, Id:=539 '6 New .Controls.Add Type:=msoControlButton, Id:=530 '7 Duplicate .Controls.Add Type:=msoControlButton, Id:=644 '8 Delete .Visible = True End With '-- Define the Close button With cmdbarNavigation.Controls(1) .Style = msoButtonIconAndCaption .Caption = "Close Form" .OnAction = "CloseActiveForm" .TooltipText = "Close Form" End With '-- Define the Duplicate button With cmdbarNavigation.Controls(7) .Style = msoButtonIcon 'AndCaption '.Caption = "Duplicate" .OnAction = "DuplicateRecord" .TooltipText = "Duplicate active record" End With Set cmdbarNavigation = Nothing End Sub '====================================================================== -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Stuart McLachlan Sent: Friday, 12 September 2008 12:44 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Controlling Custom Toolbars CommandBars("Customer").Position = msoBarTop But make sure you have a reference to the Microsoft Office Object Libarary On 12 Sep 2008 at 10:39, Darryl Collins wrote: > > Ok Folks > > That works great. Now I have a new (but related issue). How do i control the docking position on built in/ existing toolbars? > > In Excel VBA the code is > > gxltbMyToolbar.Position = 1 > > The control options being > Top 1 > Right 2 > Left 0 > Bottom 3 > Floating 4 > > It seems that 4 (floating is the default) in Access, but what is the darn syntax to get them to dock? > > I can do this if i create the command bar from scratch, but in this case I am just using commandbars I custom built using the default button set. > > > Set myBar = CommandBars.Add(Name:="Customer", _ > Position:=msoBarTop, _ > Temporary:=True) > > but I cannot figure out how to make existing toolbars behave! > > Thanks once again > > Darryl. > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Stuart > McLachlan > Sent: Thursday, 11 September 2008 4:07 PM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] Controlling Custom Toolbars > > > 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 > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > 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 -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com 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.