10 Tips Access Custom Menus
10 Tips Access Custom Menus
0
in your Access apps January 3, 2007
Note
1 Give forms and reports a default menu For most of the functions in these tips to
work, you must first reference the Microsoft
When you open a form or report, Access displays the built-in menu Office Object Library. In the Visual Basic
bar, which features the familiar menu commands (File, Edit, etc.). If Editor (VBE), select References from the
you inhibit this menu bar for a custom application, or if you want to Tools menu. Then, check the library item and
present options and tasks that are specific to that particular form or click OK.
report, you can build a custom menu bar that Access will display
instead of the built-in menu bar when the user opens the form or
report.
To do this, simply set the form’s Menu Bar property to the appropriate custom bar object using the property field’s
drop-down list. When you leave this property blank, Access displays the built-in menu bar or the application’s
global menu bar (see # 4).
To set this property using VBA, execute a statement in the following form:
Forms!frmname.MenuBar = menubarname
When using a form for different purposes, such as browsing records and data entry, you can use this property to
display different custom menus for each view. Just set the property to the appropriate menu bar, dependent on
some flag you can set or pass, when you open the form.
To reset the menu bar to the built-in menu bar, use a statement in the following form:
Forms!frmname.MenuBar = " "
3 Names matter
Each new custom menu bar you build will need a unique name. Don’t try to name any of your custom menu bar
objects Menu Bar because that’s the name of the build-in menu bar. If you try to use this name, either using the
Customize dialog box or VBA code, Access will return an error.
Consider tagging each custom bar object with a prefix that identifies the object, such as cbo or just cb, for
command bar object or command bar. The prefix is self-documenting. (Don’t use cbo if you also use that to prefix
combo box objects. Nothing bad will happen if you do, but the use of the same prefix for two different objects
might confuse you or others later.)
Page 1
Copyright ©2007 CNET Networks, Inc. All rights reserved.
For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html
10 tips for customizing menus and toolbars in your Access apps
Page 2
Copyright ©2007 CNET Networks, Inc. All rights reserved.
For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html
10 tips for customizing menus and toolbars in your Access apps
When run, the function will print the name and the CommandBar object type for each object in the current
application. The following table identifies the three types by their VB constants and integer values:
Toolbar msoBarTypeNormal 0
Popup msoBartypePopup 2
If you use the function in # 6 to document the bars in your application, you might want to identify them or even
group them by type.
Page 3
Copyright ©2007 CNET Networks, Inc. All rights reserved.
For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html
10 tips for customizing menus and toolbars in your Access apps
Page 4
Copyright ©2007 CNET Networks, Inc. All rights reserved.
For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html
10 tips for customizing menus and toolbars in your Access apps
Additional resources
TechRepublic's Downloads RSS Feed
Sign up for TechRepublic's Downloads Weekly Update newsletter
Sign up for our Desktops NetNote
Check out all of TechRepublic's free newsletters
"Create and manipulate Microsoft Access forms with VBA" (TechRepublic download)
"How do I... Create a crosstab query in Microsoft Access?" (TechRepublic download)
"10 tips for working with dates in Microsoft Access" (TechRepublic download)
Version history
Version: 1.0
Published: January 3, 2007
Thanks!
Page 5
Copyright ©2007 CNET Networks, Inc. All rights reserved.
For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html