ShortcutText Property
Applies To
CommandBarButton object.
Description
Returns or sets the shortcut key text displayed next to the specified button control when that button appears on a menu, submenu, or shortcut menu. Read/write String.
Remarks
You can set this property only for command bar buttons that have an attached OnAction macro.
Specifics (Microsoft Access)
In Microsoft Access 97, you can use the Toolbar Control Properties dialog box for command bar controls to set the shortcut text that's displayed to the right of a built-in button control on a menu, submenu, or shortcut menu. Display the Customize dialog box by pointing to Toolbars on the View menu and clicking Customize. For menu bar and toolbar controls, display the menu bar or toolbar, and then right-click the button control whose ShortcutText property you want to set. For shortcut menu controls, select the Shortcut Menus check box on the Toolbars tab of the Customize dialog box, then find the shortcut menu control you want on the menu bar that's displayed and right-click the control. Click the Properties command. Enter the shortcut text you want in the Shortcut Text box. You can set this property for any built-in button control in Microsoft Access, but not for custom button controls.
Setting this property in Microsoft Access just causes the shortcut text to be displayed next to the control. If you change or add shortcut text for a built-in control, typing this shortcut key or key combination doesn't run the command associated with this control. To run this command, you must assign the shortcut key or key combination in an AutoKeys macro. In the AutoKeys macro, assign the key or key combination to a macro that uses the RunCommand action to run the command.
For custom commands, you can't display the shortcut text next to the control, but you can use the AutoKeys macro to assign a shortcut key or key combination that will run the same set of actions as the macro or function that's the setting of the control's OnAction property. Assign the key or key combination to the desired set of macro actions, or use the RunMacro or RunCode action to run the macro or function you want this key or key combination to carry out.
Example
This example places a charting button on the command bar named "Custom" and assigns an OnAction macro to the button, along with a shortcut key and a caption.
Set myControl = CommandBars("Custom").Controls _
.Add(Type:=msoControlButton, Id:= 17)
With myControl
.OnAction = "MySub"
.Caption = "Graph Results"
.Control.ShortcutText = "CTRL+SHIFT+M"
End With