Solved

Setting initial position for a custom menu / toolbar

Posted on 1998-01-27
10
665 Views
Last Modified: 2008-06-19
I have created a toolbar and menu for a form and report I have made using Access '97.  The custom toolbars seem very powerful, since I can launch macros and VBA functions from them.  However, when I enter my form or report, the toolbar or menu is just sitting there.  Sure, I can move it and reposition and resize, but how can I code it so that it is initally docked at the top?  Is this possible?  I will be exporting this project as a stand-alone, so I am wanting, when they click on the "Create Report" option in my form, to show a report with a single menu bar above which I have created, which has various preferences.  I do not want a floating menu or toolbar.  I want it initally positioned to my liking.  Thanks!
0
Comment
Question by:mitchell042997
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 8

Expert Comment

by:Kobe_Lenjou
Comment Utility
Isn't there an 'align' property wich you can set to TOP?
0
 
LVL 2

Author Comment

by:mitchell042997
Comment Utility
I don't think so.  WHere is this align property you speak of?  Is it in the form properties, or the custom toolbar properties?  Thanks for any help!
0
 
LVL 5

Expert Comment

by:cekman
Comment Utility
Try something like this -which I got from Access 97 menubar help:
This does more than you want - but shows how to dock.....

Adding menu bars at run time

When you add a menu bar to an application at run time, you use the Add method for the CommandBars collection and specify True for the MenuBar argument. The following example adds a menu bar that cannot be moved. The example also docks this menu bar along the right side of the application window. The new menu bar becomes active whenever the user presses the ALT key.

Set menubar = CommandBars.Add _
    (Name:="mBar", Position:=msoBarRight, MenuBar:=True)
With menubar
    .Protection = msoBarNoMove
    .Visible = True
End With
0
 
LVL 2

Author Comment

by:mitchell042997
Comment Utility
I already read that in the help files.  But I couldn't get it to work.  If you can code a program which does what I want it to do, post the source code, and I will award you the points.  But to just rehash something out of the help files.  A two year old could do that.
0
 
LVL 12

Accepted Solution

by:
Trygve earned 100 total points
Comment Utility
Try this:

CommandBars("Menu Bar").Visible = True ' Mine kept disapearing

CommandBars("PIMSInfoCentre").Visible = True
With CommandBars("The name of your command bar")
  .Position = msoBarTop
  .Protection = msoBarNoChangeDock + msoBarNoChangeVisible + msoBarNoMove + msoBarNoResize
  .Visible = True
End With

These lines located a predefined bar at the top at didn't allow me to play with it (move, remove etc.)

Hope this helps !
Trygve
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:cekman
Comment Utility
<<I already read that in the help files. But I couldn't get it to work. If you can code a program which does what I want it to do, post the source code, and I will award you the points. But to just rehash something out of the help files. A two year old could do that. >>

I don't usually respond to comments like this but.....

Where in your original question does it say that you tried this command - the MAJORITY of the questions asked here could be solved by people pressing F1. I attempted to answer your question - which specifically asked about docking - which is specifically addressed in the example. I'm sorry it didn't work for you - but a simple - thanks anyway would have sufficed. Please - in the future - don't refer to someone who is sincerely trying to help you to solve a problem - as a 2-year old. It's not (IMO) professional.

It also would be VERY helpful if you would have included the code you tried - and stated exactly what it did/didn't do for you - along with any possible error messages.

I hope Trygve has given you an anser you can use.
CEkman
0
 
LVL 2

Author Comment

by:mitchell042997
Comment Utility
Where would you place that code that you presented me with?  Would you place it in a function in a global module, or could it go in the Form's OnLoad Event handler?  This menu bar is just for the form, if that helps any.  Also, is there any add-ins I need to install?  Is this a macro, or VBA code.  I ask, because trying similar code in VBA has given me errors, it doesn't recognize the CommandBars object.  (I am using Access '97, for reference's sake.)  Thank you.
0
 
LVL 2

Author Comment

by:mitchell042997
Comment Utility
Sorry to snap, CEckman, but I have had so many people lock up questions I've posted with half guesses and documentation quotation.  For example, I have asked questions before and gotten answers like, "Well, I guess you could try doing this:" and then they would cut and paste out of the help files from a category in the help files which matched my question.

Sorry to react so vehemently.  It's just frustrating (and to no fault of your own), because I do spend a lot of time before posting here, and then to see in email that the question has been answered, and then to have that answer be a snippet out of the help files I have already read over ten times...  Oh well, again, sorry for the trite response.
0
 
LVL 12

Expert Comment

by:Trygve
Comment Utility
I put the code in the OnOpen Event for the form. I have rewritten it a bit, because my initial proposal include parts from my test.

CommandBars("Menu Bar").Visible = True

With CommandBars("Toolbox") ' Toolbox menubar used as example
  .Visible = True
  .Position = msobartop ' 1
  .Protection = msoBarNoChangeDock + msoBarNoChangeVisible + msoBarNoMove + msoBarNoResize
  .Visible = True
End With

This worked without error in my test. If you get any errors, regarding the CommandBars collection or others, please let me know.
0
 
LVL 2

Author Comment

by:mitchell042997
Comment Utility
It worked.  There was one thing, though, that if you get asked this question or one similar, you may want to add.  You need to go to Tools / References in the code editor and add Microsoft Office Tools 8.0.

Thanks for your help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now