Microsoft Access 2000 provides a user interface for adding and modifying shortcut menus. To add a custom shortcut menu, add a toolbar in the Customize dialog box, available by pointing to Toolbars on the View menu and clicking Customize, and then use the Toolbar Properties dialog box to change the Type of the toolbar to Popup. To delete a shortcut menu, you must change its type to Menu Bar or Toolbar, and then delete it. You can add, modify, and delete any shortcut menus in Visual Basic.
Built-in and custom shortcut menus are displayed in the Shortcut Menus toolbar, available by selecting the Shortcut Menus check box in the Customize dialog box. You can add and remove command buttons and menu items to and from shortcut menus by using the Shortcut Menus toolbar. Note, however, that to refer to a shortcut menu in Visual Basic, use the syntax CommandBars("shortcutmenuname"). The code CommandBars("Shortcut Menus")
is meaningless.
You can use an event procedure to display a shortcut menu in response to a right mouse click. The following example displays the custom shortcut menu "CustomerFormShortcut" when the user right-clicks in a blank area or record selector on a form.
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Dim cmdBar As CommandBar
Dim intRight As Integer
Set cmdBar = CommandBars("CustomerFormShortcut")
intRight = (Button and acRightButton) > 0
If intRight Then
cmdBar.ShowPopup 200, 200
End If
End Sub