ACC: ShortcutMenuBar Property Does Not Work on Image or Label (166293)
The information in this article applies to:
- Microsoft Access for Windows 95 7.0
- Microsoft Access 97
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:
- 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.
- Set the Transparent property of the command button to Yes.
- 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.
REFERENCES
For more information about using shortcut menus in Microsoft Access, search
the Help Index for "shortcut menus," or ask the Microsoft Access 97 Office
Assistant.
For more information about the ShortcutMenuBar property, search the Help
Index for "ShortcutMenuBar property."
Modification Type: | Major | Last Reviewed: | 10/20/2003 |
---|
Keywords: | kbprb KB166293 |
---|
|