I am adding a row of controls in a “For each” loop. I just realized I needed to add a CommandButton. No problem. However, how do I add code to the Click event for each of these dynamically added CommandButtons? I don’t know in advance how many of these buttons will be created.
I am using the following code in the middle of the “For each” loop to add the CommandButton:
Set MyCommandButton1 = frmAnalyzeListFormat.Controls.Add(“Forms.CommandButton.1”, “MyCommandButton1_” & MyCommandButton1Number)
MyCommandButton1.Height = 18
MyCommandButton1.Width = 45
MyCommandButton1.Top = PreviousLabelRowHeight + 17
MyCommandButton1.Left = 282
MyCommandButton1.Caption = “Show Me”
P.S. The code for the click event will be the same for each button, but I want to add a button for each row to prevent confusion and for usability.
Thanks!! Troy