Article ID: 198464 - View products that this article applies to.
This article was previously published under Q198464
Novice: Requires knowledge of the user interface on single-user computers.
This article shows you how to dim or disable items on a menu bar, toolbar, or shortcut menu in Microsoft Access.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
The CommandBars collection in Microsoft Access exposes all menu bars, toolbars, and shortcut menus in your application to Visual Basic for Applications so you can manipulate them programmatically. By using the properties and methods of the CommandBars collection in your application, you can manipulate and customize both built-in and custom command bars.
NOTE: If you use Windows application programming interface (API) procedures to manipulate menus in your Microsoft Access 2.0 or 7.0 database, you must modify the code to use the CommandBars object model in Visual Basic for Applications when you convert your database to Access 2000. Windows API calls do not work with Microsoft Access 2000 menus, toolbars, or shortcut menus.
Each command bar, whether it is a menu bar, a toolbar, or a shortcut menu, consists of a collection of CommandBarControl objects. You can create three types of CommandBarControls on a command bar, each with its own methods and properties:
ExampleThe following example shows you how to disable or enable items on a menu bar or toolbar based on events in your application.
NOTE: For this example to work in your own database, make sure that your database has a reference to the Microsoft Office 9.0 Object Library. Northwind.mdb has this reference set by default, but your database may not. To set a reference to the Microsoft Office 9.0 Object Library, click References on the Tools menu in the Visual Basic Editor, and then click to select the Microsoft Office 9.0 Object Library check box.
For more information about command bars, click Microsoft Access Help on the Help menu, type "command bars" in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.
For additional information about creating and modifying command bars usingVisual Basic for Applications, click the article number below to view the article in the Microsoft Knowledge Base:
(https://support.microsoft.com/kb/209974/EN-US/ )ACC2000: How to Create Command Bars by Using Visual Basic Code
Article ID: 198464 - Last Review: October 11, 2006 - Revision: 3.2