Solved: OnClick event - pass this control to method
Hi all
how do i tell a method to do something to a clicked control?
I have a form with a bunch of labels and a bunch of buttons, and I want to run a method whenever one of these controls is clicked:
So far, so good, but how do i code the OnClick event method for each control? Currently I am trying to use ActiveControl:
but am getting 'Runtime Error 2474: The expression you entered requires the control to be in the active window'. The control is in the active window (coz I just clicked on it).
What should I be doing?
tia,
mcalex
Hi all
how do i tell a method to do something to a clicked control?
I have a form with a bunch of labels and a bunch of buttons, and I want to run a method whenever one of these controls is clicked:
Code:
Private Sub manipulateControl(ByRef ctrl As Control)
If (TypeOf ctrl Is Label) Then
with ctrl
' do stuff that changes the clicked label
end with
ElseIf (TypeOf ctrl Is Button) Then
with ctrl
' do stuff to the clicked button
end with
End If
End Sub
So far, so good, but how do i code the OnClick event method for each control? Currently I am trying to use ActiveControl:
Code:
Private Sub Label74_Click()
manipulateControl Me.ActiveControl
End Sub
What should I be doing?
tia,
mcalex
Last edited: