
There is no "Exists" function we can call to see if a certain command bar has already been created. The CommandBars are stored in a collection. The safest way to avoid naming collisions with the existing command bars is to use a two- or three-character prefix as part of the cmmand bar name. For these shortcut menus, I advise you to avoid them entirely and create completely new command bars instead. A Brief Note About Built-in Command Bars There are hundreds of built-in command bars. But the feature itself still remained, lurking in the shadows. With the introduction of the ribbon in Access 2007, that feature was removed from the development user interface. In Access 2003 and earlier, you could create custom command bars through the user interface.
#Shortcut menu bar access 2013 code
This code should safely run in all supported versions of Microsoft Access. Neither situation applies to the CommandBars-related objects and methods of the Office Object Library that we will be using. Early binding to object libraries can cause compatibility issues when you are dealing with either (A) a library with no regard for backward compatibility or (B) you are using new features that may not exist in old versions of the library. TECHNICAL NOTE: This is an example of early binding. 0 Object Library." The version number will match your version of Access it will be something like 15.0 or 16.0. In VBA, go to Tools > References and check the box next to the reference named, "Microsoft Office. And even though this is a versioned library, the parts of the Office Object Library we will be using have been in place since well before Access 2007. The reference is not strictly necessary (you can use late-binding instead), but having access to IntelliSense and the Object Browser make the development experience more pleasant.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" "). You can also use the ShortcutMenuBar property to specify the menu bar macro that is used to display a shortcut menu for a datasheet, form, form control, or report. The ShortcutMenuBar property applies only to controls on a form, and not to controls on a report. SyntaxĮxpression A variable that represents a ListBox object.

Use the ShortcutMenuBar property to specify the shortcut menu that appears when you right-click the specified object.
