Solved How to pass parameters to a function via context menu bar? (1 Viewer)

KitaYama

Well-known member
Local time
Tomorrow, 04:29
Joined
Jan 6, 2022
Messages
1,560
I have a button on a form that clicking it brings up a menubar with several controls.
Then selecting each control, will execute a function.
Here's a simplified version of what I have :

Code:
Dim Mnu As CommandBar
Dim itm As CommandBarControl

Set Mnu = CommandBars.Add("", msoBarPopup, , True)
Set itm = Mnu.Controls.Add: itm.Caption = "Control1": itm.OnAction = "Function1"
Set itm = Mnu.Controls.Add: itm.Caption = "Control2": itm.OnAction = "Function2"
    
Mnu.ShowPopup

The above works perfect.

The advice I need:
How can I pass one or more parameters to these functions?
I tried
itm.OnAction = "Function1(100,200,300)"

but after adding the parameters, nothing happens. Function1 is not executed.


thank you.
 

June7

AWF VIP
Local time
Today, 11:29
Joined
Mar 9, 2014
Messages
5,490
Solution

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:29
Joined
May 7, 2009
Messages
19,246
maybe create a Global array/collection to hold the values you want to use in your function.
you can destroy the array/collection when you are done with the function.
see Form1 from this demo.
 

Attachments

  • dbCommandbar.accdb
    864 KB · Views: 70

Users who are viewing this thread

Top Bottom