Microsoft KB Archive/166293

= ACC: ShortcutMenuBar Property Does Not Work on Image or Label =

Article ID: 166293

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q166293



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you set the ShortcutMenuBar property of an image control or label control on a form to the name of a custom shortcut menu, right-clicking the control causes the default shortcut menu for the form to appear.



CAUSE
The ShortcutMenuBar property does not work with controls that cannot receive the focus.



RESOLUTION
Use one of the following methods to work around this behavior, depending on your version of Microsoft Access.

Method 1: Microsoft Access 7.0 and 97
Place an invisible command button on the form and use it to invoke your custom shortcut menu:


 * 1) Add a command button control to the form. Place it on top of the image or label control, and size it to cover the image or label completely.
 * 2) Set the Transparent property of the command button to Yes.
 * 3) Set the ShortcutMenuBar property of the command button to the name of the custom shortcut menu that you want to display.

Method 2 (Microsoft Access 97)
You can use the MouseDown event of the image or label control to invoke the ShowPopup method of your custom shortcut menu. In order to use this method, your custom menu must have its Type property set to PopUp, which is a requirement for any shortcut menu.

This example assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.

Set the MouseDown event of the image or label control to the following event procedure. This example assumes a control named Image0, and a shortcut menu named Custom1; substitute the names of your own control and shortcut menu in the procedure.

Private Sub Image0_MouseDown(Button As Integer, Shift As Integer, _     X As Single, Y As Single) 'If the right mouse button is pressed, show the custom shortcut menu If Button = acRightButton Then CommandBars![Custom1].ShowPopup End If  'Cancel the event so the form's default shortcut menu does not appear DoCmd.CancelEvent End Sub



STATUS
This behavior is by design.

