Calling event procedure of control variable

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
 
A

Allen Browne

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.
 
M

Mark A. Sam

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?
 
M

Mark A. Sam

Thank you Allen,

I worked it out by modifying the function.

God Bless,

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top