Calling event procedure of control variable

  • Thread starter Thread starter Mark A. Sam
  • Start date Start date
M

Mark A. Sam

In the following code:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = 48 Then
Call ????? <Need to call Click Event of ctl.>
End If
Next ctl

I need the syntax to call the Click Event of the control represented by the
variable ctl.

Thanks for the help and God Bless,

Mark A. Sam
 
Hi Mark.

I don't think VBA will allow you to call a procedure by specifying its name
in a string variable, i.e. you cannot Eval(ctl.Name & "_Click")

Is there a chance that you could write a generic routine to handle all the
code, and call that? Example:

Function DoSomething(ctl As Control)
Select Case ctl.Name
Case "Something"
'put the code here
Case "Another one"
'put code here
End Select
End Function

Another alternative might be to place the name of a macro into the OnClick
property, so you can read the property and run the macro.
 
Actually, I have a common function on the onclick propertites. Could I call
the function or would I have to call if from a macro?
 
Back
Top