Solved Using shared functions for context menu items

KitaYama

Well-known member
Local time
Tomorrow, 04:10
Joined
Jan 6, 2022
Messages
1,769
Short question:
When I right click a form and click one of the items in the user defined shortcut menu bar, Is there any way to recognize which item (button/menu) has been clicked?

Detailed:
One of my forms has a user defined shortcut menu bar.
I have several menu (Buttons) on this context menu, that fire different functions. The functions are identical to each other, and only two or three lines of the code is different.
When I edit one of these functions, I have to edit all others too.

I'm trying to merge all functions into one, and add an Select statement for the different part.
But for this, I have to know which item has been clicked.
When the function is executing, how can I check which item has been clicked?


If Google translate is not clear enough, Check the attachment.
Open the attachment. Right click the empty form. Click each item and see the result. Two different functions are used for this.
How can I merge two functions into one and have the same result.

Thanks for your time.

SQL:
Set cmbRightClick = CommandBars.Add(cbName, msoBarPopup, False, True)
 
With cmbRightClick
    Set cmbCtl = .Controls.Add(Type:=msoControlButton)
    With cmbCtl
        .Caption = "Button1"
        .OnAction = "MyFunction1"
        .Parameter = "Button1"
        .FaceId = 226
        .BeginGroup = True
    End With
   
    Set cmbCtl = .Controls.Add(Type:=msoControlButton)
    With cmbCtl
        .Caption = "Button2"
        .OnAction = "MyFunction2"
        .Parameter = "Button2"
        .FaceId = 226
        .BeginGroup = True
    End With
   
End With
 

Attachments

Users who are viewing this thread

Back
Top Bottom