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

MenuBar/Toolbar Position

Status
Not open for further replies.

MeisoT

Technical User
Apr 25, 2004
43
US
I have one custom menubar and one custom toolbar that should both be visible at the same time with the same form. The problem is that when the form opens, the toolbar and the menu bar keep changing their positions, seemingly at random. Sometimes the menubar is on top of the toolbar, and sometimes the toolbar is on top of the menubar.

I would like the menu bar to be at the very top and the toolbar to be right below the menu bar every single time.

I tried using the following code to accomplish this but it does not work:

Dim myBar As CommandBar
Dim myBar2 As CommandBar

Set myBar = CommandBars("xMenuBar")
myBar.Position = msoBarTop
With myBar
.Left = 0
.Top = 0
End With


Set myBar2 = CommandBars("xToolbar")
myBar.Position = msoBarTop
With myBar2
.Left = 0
.Top = 45
End With

Does anybody know how to make these two commandbars remain in their relative positions every time the form opens???
 
Hallo,

Shouldn't myBar.Position for your second toolbar be myBar2.Position ?
Wouldn't have that problem if you included the line inside the With.

- Frink
 
You are correct Frink, I mispelled "myBar2" on the second declaration. I corrected the spelling error and put the position declaration inside the 'With' as you suggested, but the toolbars still do not show in their proper positions.

This is the corrected code that is still not working properly (I tried using a 'Top' position of 100 for the second toolbar this time around):

Dim myBar As CommandBar
Dim myBar2 As CommandBar

Set myBar = CommandBars("OpenForms")
With myBar
.Position = msoBarTop
.Left = 0
.Top = 0
End With


Set myBar2 = CommandBars("tlbrDataEntry")
With myBar2
.Position = msoBarTop
.Left = 0
.Top = 100
End With

Do you have any other suggestions?

 
Hallo,

Have you looked at the ShowPopup method?
I don't know if it's what you want but it might be helpful,

- Frink
 
Thanks for your reply Frink. I forgot to mention that the version of Access I am using is 2000. I don't think that the ShowPopup method exists in the 2000 version.

Anyway, I was able to work around the problem by keeping both the menubar and toolbar visible across all forms (instead of hiding the entire toolbar/menubar) and enabling/disabling specific buttons on the toolbars.
 
How are ya MeisoT . . . . .

Before you get into all this code (I've never had a problem here), have you tried [blue]locking the Bars?[/blue]
[ol][li]Open the form that brings up the bars and [blue]line them up as desired.[/blue][/li]
[li]Click [blue]View[/blue] - [blue]ToolBars[/blue] - [blue]Customize[/blue].[/li]
[li]For each bar, [blue]select the bar in the list & click Properties[/blue]. [purple]Remove check from Allow Moving.[/purple][/li][/ol]
This may be all you need . . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top