Call a function

Hey again experts: I convert the Access switchboard macro to VBA today. I now have another problem that I cannot figure out. When the macro was converted it placed a call to a public function but it never worked. This is what it is trying to do: CALL ARGUMENT & "()" but it doesn't work. The argument is a string to the function "ExitDB". Any ideas?
stevensontAsked:
Who is Participating?
 
mbizupConnect With a Mentor Commented:
Oh!  Okay....

try this -

Dim ARGUMENT as string
ARGUMENT = "ExitDB()"
Eval(ARGUMENT)

Open in new window

0
 
mbizupCommented:
The code would be like this:


If ExitDB is the name of your function, you would call it like this:


Call ExitDB(ARGUMENT)   '<--- This assumes that ARGUMENT is a string vatiable you need to pass to the ExitDB function

Open in new window


Equivalent code would be:
ExitDB  ARGUMENT

Open in new window

0
 
stevensontAuthor Commented:
Thanks, but argument is the string containing the function name ExitDB.
0
 
stevensontAuthor Commented:
The eval function solved the problem
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.