I have a form which has 22 command buttons on it, I have written a procedure which formats the command button when it is clicked, but the way i see it at the momment I have to write 22 slightly different procedures i.e one for each of the buttons.
What I want to do is write a procedure which can identify which button(s) have been clicked. I did think of storing the button name in an array but i can't seem to think of a way of collecting the button name.
its this statment from the procedure below that I want to get rid of or change just so that I don't have 22 slightly different procedures.
Var_Which_Btn_Pressed = "btn_Aircraft_Selector_Plane01"
The procedure for one button is shown in total below
Thanks for any input you can give.
Private Sub btn_Aircraft_Selector_Plane01_Click()
Var_Which_Btn_Pressed = "btn_Aircraft_Selector_Plane01"
Last_Two = Right(Var_Which_Btn_Pressed, 2)
If Me(Var_Which_Btn_Pressed).Caption = "C" Then
Array_Which_Button_Pressed(Last_Two) = ""
format_btn_selected
ElseIf Me(Var_Which_Btn_Pressed).Caption = "D" Then
Array_Which_Button_Pressed(Last_Two) = Right(Var_Which_Btn_Pressed, 5)
format_btn_not_selected
End If
End Sub
What I want to do is write a procedure which can identify which button(s) have been clicked. I did think of storing the button name in an array but i can't seem to think of a way of collecting the button name.
its this statment from the procedure below that I want to get rid of or change just so that I don't have 22 slightly different procedures.
Var_Which_Btn_Pressed = "btn_Aircraft_Selector_Plane01"
The procedure for one button is shown in total below
Thanks for any input you can give.
Private Sub btn_Aircraft_Selector_Plane01_Click()
Var_Which_Btn_Pressed = "btn_Aircraft_Selector_Plane01"
Last_Two = Right(Var_Which_Btn_Pressed, 2)
If Me(Var_Which_Btn_Pressed).Caption = "C" Then
Array_Which_Button_Pressed(Last_Two) = ""
format_btn_selected
ElseIf Me(Var_Which_Btn_Pressed).Caption = "D" Then
Array_Which_Button_Pressed(Last_Two) = Right(Var_Which_Btn_Pressed, 5)
format_btn_not_selected
End If
End Sub