Gustav Brock
gustav at cactus.dk
Fri Aug 17 05:56:29 CDT 2012
Thanks Philippe It sounds right but I just found out how by help from an Experts-Exchange member. The magic method is OnAction. Here is an example with no macros. The first part is what you usualla see, the second part is what I've requested - calling custom functions. <code> Public Function CreateCMenu() On Error Resume Next CommandBars("MyContext").Delete Dim cmb As CommandBar 'Object Dim cmbBtn1 As CommandBarButton 'Object Dim cmbBtn2 As CommandBarButton 'Object Set cmb = CommandBars.Add("MyContext", _ msoBarPopup, False, False) ' msoBarPopup = 5 With cmb ' add cut, copy, and paste buttons with the ' "magic number" technique that assigns ' appearance and behavior. The magic number ' goes in as the second parameter .Controls.Add msoControlButton, _ 21, , , True ' 21=Cut, msoControlButton=1 .Controls.Add msoControlButton, _ 19, , , True '19= Copy .Controls.Add msoControlButton, _ 22, , , True ' 22=Paste ' add customized buttons with our caption and ' function name -- second param is blank Set cmbBtn1 = .Controls.Add(msoControlButton, _ , , , True) With cmbBtn1 .BeginGroup = True .Caption = "Create New" .OnAction = "=CreateNewOrder()" .FaceID = 59 'smiley face End With Set cmbBtn2 = .Controls.Add(msoControlButton, _ , , , True) With cmbBtn2 .Caption = "Reset" .OnAction = "=ClearOrder()" .FaceID = 27 'some other icon End With End With End Function </code> To make it temporary, change the last parameter to True: Set cmb = CommandBars.Add("MyContext", _ msoBarPopup, False, True) Finally, adjust your form: Properties->Other->Shortcut Menu=Yes Properties->Other->Shortcut Menu Bar=MyContext /gustav >>> phpons at gmail.com 17-08-12 11:55 >>> Gustav, Here is a link where you can download a events.xlsm Excel workbook with a code to create a popup menu. I guess it could be used in access the same way. http://gallery.technet.microsoft.com/Excel-2010-Code-Example-ad66f451 Regards, Philippe 2012/8/17 Gustav Brock <gustav at cactus.dk> > Hi Charlotte > > No, unfortunately not, that link is about the ribbon. > My popup menu will be completely separated from that. > > /gustav > > > >>> charlotte.foust at gmail.com 17-08-12 5:28 >>> > I haven't done it in years in Access. Does this help? > > http://www.accessribbon.de/en/index.php?FAQ:9 > > Popup menus seemed to have devolved into context sensitive ribbons, which > aren't the same thing at all. > > Charlotte > > On Thu, Aug 16, 2012 at 10:19 AM, Gustav Brock <gustav at cactus.dk> wrote: > > > Hi all > > > > So this would be one of the tough questions at a job interview? > > > > Has no one created a popup-menu? > > > > /gustav > > > > > > >>> gustav at cactus.dk 15-08-12 18:23 >>> > > Hi all > > > > I need some help with this. > > > > I've found out that you need a reference to the Office Object Library and > > then create a "commandbar" to achieve this, but the code examples I can > > locate just adds standard Access/Office commands to the menu using > "secret" > > values. > > > > My popup should be displayed when right-clicking the form outside the > > controls. > > It should contain a few menu entries, say: > > > > Create New > > Reset > > > > When clicking one of these, a function of mine should be called, like: > > > > CreateNewOrder() > > ClearOrder() > > > > No fancy icons or the like is needed. > > > > I've managed to create a shortcutmenu (macro) but, when I right-click, no > > menu is shown - the macro is executed right away. > > > > /gustav > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com