Private Sub Form_Load()
CreateSimpleShortcutMenu
Me.Field1.ShortcutMenuBar = "ShowDataShortcutMenu"
End Sub
Sub CreateSimpleShortcutMenu()
Dim newMenu As CommandBarControl
Dim cmb As CommandBar
On Error Resume Next 'If menu with same name exists delete
CommandBars("ShowDataShortcutMenu").Delete
'CommandBars("ShowDataShortcutMenu").Delete
Set cmb = CommandBars.Add("ShowDataShortcutMenu", msoBarPopup, False, False)
With cmb
.Controls.Add msoControlButton, 11725, , , True
End With
Set cmb = Nothing
Set newMenu = Nothing
End Sub
Did you run that procedure from the immediate window after you pasted it into a standard code module, not the report code module? If not, do so using the immediate window:
Call CommandbarTest
Once you have run that code, you should see a dropdown list in the Shortcut Menu property of the report.
You only want this code to run once, period. You want to set the "Temporary" argument for both the Comandbar and the control to FALSE, this way you don't need to call this procedure ever again, ever.
But if you do this, you don't want to do:
Application.CommandBars(menuName).Delete
Where did you get the FaceID = 42?
John,
I don't understand why you keep encouraging him to make this a temporary commandbar/control and set the ShortcutMenuBar property at run-time. If you define the commandbar and control as permanent ([Temporary] = False) then you never need to run that code again, and can simply set the ShortcutMenuBar property of the report to the menu name.
Dale
urjudo,
I'm going to back out of this question. John and I. although using similar techniques, are just confusing you, so I'm going to let you work with John from here on out.
Dale
John,
I would encourage you to download the Access Shortcut Tool, much easier to use than the method in 2003.
Dale
Did you download and install the Access Shortcut Tool, hyperlinked in my first post?
This tool was designed to replace the method used in A2003 and has made it very easy for me to make Shortcut menus over the last 4 years. Give it a try.
It's not read only, but if you are trying to launch it from within the zip file, it would be.
There is a text file with instructions in the zip file; follow those instructions to install it so that you can use it to create short-cut menuse within all of your Access applications.
There are a lot of features of the full version which are not available in the Runtime version.
Access will not let you use the built-in shortcut menus in the run-time environment, but you can create and use your own. One way to do this is to copy the print menu and rename it, then remove all of the items I'm not interested in. The easiest way I know to do that is to use the Access Shortcut Tool. Which makes it easy to copy an existing shortcut menu or create your own, from scratch. What I do is create a shortcut (right click) menu for all my reports, with options, Print, Save as PDF, Send as attachment, Export to Excel, and Close.
These article should help you get a better understanding of short-cut menus
Understanding and using Commandbars
Understanding and using Commandbars, Part II
Commandbars (Part III) - Using built-in menus
Using shortcut menus in Access run-time environment