How to run a function from a variable

G

Gussie

Hello everyone, I have been trying to dynamically run a function that is
stored in a variable (this comes from an Access table). To make to story
short:

strSomeFunction = "ExportRecords"

then I would like to call it:

Run strSomeFunction

There is no EVAL() function - I am not referring to the EVALUATE Excel
function.

Any ideas?
 
D

Daniel.C

Hi,
Try :

strSomeFunction = "ExportRecords"
Application.Run strSomeFunction

Regards.
Daniel
 
J

Joel

You can pass parameters in the Run Function.

Run strSomeFunction("ExportRecords")


You SQL statements in Access are string which can take parameter


Function strSomeFunction(Mytable as String)

SQL = ".............table(" & Mytable & ").........................."

end function

The query statements in Access are Strings. You can put a passed parameter
into the SQL string by breaking the string into pices like I done above.
 
G

Gussie

Daniel C, got it right.

The strSomeFunction is a string variable that will be loaded with the
function name which is stored in a table, then I can just run it

SQL statement
code
code
strSomeFunction = rsSource!FunctionName

Application.Run strSomeFunction

It works like a charm!
 
G

Gussie

Thanks Daniel, it works like a charm.
I missed that command, I looked everywhere but did not think of the
application.

Thx again
 

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