Custom MenuBar cannot be hidden

Ö

Ömer Ayzan

Dear Friends,
I am a Access 2000 user, running under WinXP professional.
I have created a custom menu bar by using customize menu bar and assigned
it to all of my forms as the only menubar.
However on a certain form I want that menu bar hidden. So on the activate
event of this form I have the following code:

Private Sub Form_Activate()
MBarUtil "ptsMenuBar", False
End Sub

and the function is:

Public Function MBarUtil(MBar as string,Visibility As Boolean)
Dim cmdbar As CommandBar

Set cmdbar = Application.CommandBars(MBar )

With cmdbar
.Visible = Visibility
.Position = msoBarTop
End With
End Function

References to access are:

- Visual Basic For Applications

- Microsoft Access 9.0 Object Library

- OLE Automation

- Microsoft ActiveX Data Objects 2.1 Library

- Microsoft Office 9.0 Object Library



So far very simple, but when the form is open even though the function sets
the visibility of the menu bar to false Menu bar is still shown.
However when I click on a different form then this form again thereby
inactivating and reactivating it, the menu bar is hidden.
How can I fix this problem so that when the form is first open its menu bar
is hidden

Thanking in advance,
Omer Ayzan.
 
A

Albert D. Kallal

To manage the automation change of menus bars for forms, you best approach
would be to not specify ANY menu bar for all the forms. You then specify the
menu bar for the whole application.

Then, for forms that you want a different menu bar..you simply specify in
the form..and then you don't need any code. If you do this, then ms-access
will hide the main menu bar, and show only the bar for the form.

If you start writing code to show/hide which menu bar you need..then when
you switch to other forms..then this will become a complex programming
task...
Try downloading the sample application here:

http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm
Choose the 2000 merge example with "interface hidden"

If you look at the above, and play with it...you can see that each new form
shows a new menu bar, and all kinds of options change. Yet no code was
needed....

So, I would simply specify a "main" menu bar for the application
(tools->startup->menu bar). Then for forms were you need a different menu
bar to display, you simply specify the menu bar to show in the forms "other
tab". So, just leave all forms menu bar setting blank..except for the ones
that you need to show a different one. This approach means no code.

Also, make sure all of the menus you have are hidden when you are
developing the application (that is you enter your application via the shift
key by-pass...and then hide all of your custom menu bars...none should be
showing. You then set the main menu bar in tools->startup..and the result
will thus just work without any code.

If you have to start coding hiding/showing menu bars when a person simply
changes the form, or clicks on a different form, or another form launches
etc...you will have wear your fingers out trying to code all the possible
cases. The above approach means that ms-access will do all the work for
you...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top