I am writing a piece of VBA code for a dialog form.
The dialog form is populated with 1 to 30 buttons from the outcome of another form.
I know I can use the onclick event in each button, but the number of buttons varies, depending on the outcome from another form. The buttons are named & numbered incrementally, eg 10 buttons present: the first button is named CmdBtn1; the second CmdBtn2 and so on.
In this context the buttons are both temporary and dynamic; clicking button 1 will activate a report with characteristics a, b, c, but the next time button 1 is presented its report characteristics might be x, y, z. Characteristics a, b, and c might be associated with button 4 or 20 - it is totally arbitrary and random.
What I want to do is detect the click of one of these dynamic buttons, but I'm stuck at this point.
My thoughts so far are:
1. Use the Form_Click event (since the form is static)
2. In VBA module, cycle through each dynamic button control
Does anyone have a few clues about "button detection" events??
thanks, as always
RK
The dialog form is populated with 1 to 30 buttons from the outcome of another form.
I know I can use the onclick event in each button, but the number of buttons varies, depending on the outcome from another form. The buttons are named & numbered incrementally, eg 10 buttons present: the first button is named CmdBtn1; the second CmdBtn2 and so on.
In this context the buttons are both temporary and dynamic; clicking button 1 will activate a report with characteristics a, b, c, but the next time button 1 is presented its report characteristics might be x, y, z. Characteristics a, b, and c might be associated with button 4 or 20 - it is totally arbitrary and random.
What I want to do is detect the click of one of these dynamic buttons, but I'm stuck at this point.
My thoughts so far are:
1. Use the Form_Click event (since the form is static)
2. In VBA module, cycle through each dynamic button control
Code:
For each ctl in Me.Controls
If ctl.Controltype = acCommandButton then
...
some code here to detect the button click,
grab the button name/criteria
...
Next
...
do the other stuff here
Does anyone have a few clues about "button detection" events??
thanks, as always
RK