Solved

Setting initial position for a custom menu / toolbar

Posted on 1998-01-27
10
668 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
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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 100 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

828 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