I'm trying to create a popup command bar with a few options. I'd like to click on a command button on my form to trigger the display of the popup. The trouble is, as soon as I click on the command button, each list item's action executes, and after the actions execute, the popup menu appears but doesn't actually do anything. I'm sure I'm doing something wrong as I've never been able to get this to work since using it with the old 2003 method. Can someone help? This is the code that executes when the button is pressed (and is supposed to show the popup and let users select an option)
Code:
Public Function OppMenu() As Integer
Dim oMenu As CommandBar, oItem As CommandBarControl
Set oMenu = CommandBars.Add("", msoBarPopup, , True)
With oMenu
Set oItem = oMenu.Controls.Add: oItem.Caption = "New Opportunity": oItem.OnAction = MsgBox("New") 'NewOpp("frmPopoutOpps")
Set oItem = oMenu.Controls.Add: oItem.Caption = "Delete Opportunity": oItem.OnAction = MsgBox("delete") 'cmdDelete("listopportunities", 1)
Set oItem = oMenu.Controls.Add: oItem.Caption = "Opportunity History": oItem.OnAction = ""
Set oItem = oMenu.Controls.Add: oItem.Caption = "Opportunity Summary": oItem.OnAction = ""
End With
oMenu.ShowPopup
End Function