Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup menu on a button click 1

Status
Not open for further replies.

novice001

Programmer
Jun 7, 2002
18
US
Hello,

Guys, do you know if there's a way to show a popup menu when user clicks a command button?

Something like button "Print" on a form that will show a small menu with choices "Report1", "Report2", etc

Thanks! I will really appreciate any help.
 
If by "popup menu" you mean a shortcut menu, I don't believe you can do this. Access won't display a shortcut menu in response to DoCmd.ShowToolbar.

You could use an Office Toolbar-type CommandBar instead, but that has a little problem: it wouldn't be displayed modally, so the user could click the Print button to show the "menu", and then do something besides clicking a button on the menu. For instance, the user could close the form or click on another form, and the menu would be left displayed inappropriately.

What I would recommend is that you simulate a popup menu using an actual form. Set the form's Modal and Popup properties to Yes, and its Border Style to None. Use command buttons with the Flat special effect to print the reports. When the user clicks the Print button, you just open the form. When the user clicks one of the menu buttons, open the report and close the popup form.

Include a Cancel button to let the user close this form without selecting any report. (Normally, clicking outside the menu would make it disappear, but you can't make that work with a form.)

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Hi, This is quite possible to do.

1. Create your print procedures using a Macro. Example:
Macro Name: Report1
Action: OpenReport
Report Name: rptAuthors
View: Print Preview
2. Create your ShortCut menu:

A. Right Click on any Menu Bar or select Tools >> Customize from the Menu.

B. Select the Toolbars Tab from the Customize Window.

C. Click the New button.

D. Type in a Name for the Menu. Maybe “Shortcut1”

E. Click on the Commands tab.

F. Select “All Macros” from Categories.

G. Drag your Macros which should appear under heading Commands (will be prefixed with Macro Name)to the very small Window that should have appeared. It’s Caption will say “Sh....” or the start of whatever you decided to call the Menu.

H. Once you have finished adding the commands to the menu, right click on each item, in properties, type in the text that you want to appear in the popup menu.

I. Select the Toolbars Tab again.

J. Click the Properties button.

K. From the Select Drop Down list select PopUp. You will get a Message, read it and possibly write it down. It tells you how to edit the Menu if you need to make any changes. Click OK, then Close.

L. Close the Customize Window.


3. Paste this into the Decalrations section of a Module:
Public glShortCutMenu As Boolean


4. Paste this into a Module:
Function SetShortCutMenu()
On Error Resume Next
If glShortCutMenu = True Then
Screen.ActiveForm.ShortcutMenu = False
Screen.ActiveForm!Sub1.SetFocus
glShortCutMenu = False
End If
End Function


5. Paste this into the On Mouse Down event of the Print button:
On Error Resume Next
If glShortCutMenu = False Then
Me.ShortcutMenu = True
glShortCutMenu = True
End If


6. Paste this into the On Mouse Move Property of your Form, Form Header, Detail and Footer. If you have a Sub Form, repeat in the Sub Form:
=SetShortCutMenu()


7. I have posted a working example of this, so that you can see how it works and where everything goes at: the file to look at is Buttons/Sorting/Find/Cascading Combos/Various Examples and the example is Shortcut Menu Example.

Bill

BTW. Posted this in error to the wrong thread: thread702-675869 on 12/10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top