Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you call or execute a sub name passed into a sub via a parm

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
I have a generic function I use with ActiveControl on a form. It works for almost all cases, but a few times I need it to do a little bit more. I would like to pass in another sub as a parm and have it execute it something like the following:

GenericFunction(ctl As Control, Optional Another1 As String)

If Len(Another1) Then
Application.Run Another1
End If

etc.

I know I can't use Eval because that requires a function to be passed to it, but is there an equivalent or am I missing something obvious?

The Another1 above is a form class sub. No matter how I qualify it: "Form_frmName.Another1", "frmName.Another1",
"ME.Another1", etc I get the error message that Access can't find it.

My generic function is also contained in the form class module. I am invoking it as
=GenericFunction(screen.ActiveControl) in the On Got Focus event of my form controls to do some special processing. I am hoping to avoid having separate ones for each control and don't want to put in a case statement to execute Another1.

Thanks in advance for any help and have a great day!

Please remember to give helpful posts the stars they deserve! This makes the post more visible to others in need![thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top