?
Solved

Setting initial position for a custom menu / toolbar

Posted on 1998-01-27
10
Medium Priority
?
671 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 8

Expert Comment

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

Author Comment

by:mitchell042997
ID: 1966772
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
ID: 1966773
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:mitchell042997
ID: 1966774
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 300 total points
ID: 1966775
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
 
LVL 5

Expert Comment

by:cekman
ID: 1966776
<<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
ID: 1966777
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
ID: 1966778
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
ID: 1966779
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
ID: 1966780
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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

764 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