Help -- Using variables for Function names... 
Author Message
 Help -- Using variables for Function names...

  Maybe I'm off base here but I was trying to use a variable to represent a
function name in a Call statement.

  Here's the original:
            Call SomeFunction(argument1, argument2)

  Here's what I tried:
            Dim SomeVariable as Variant
            SomeVariable = "SomeFunction"
            Call SomeVariable(argument1, argument2)

  It bombs out. Every different variable type I've tried also bombs out. Do I
have the syntax wrong? Am I trying something that is impossible? Any advice
would be welcome -- Thanks in advance.

  TimK



Mon, 02 Oct 2000 03:00:00 GMT  
 Help -- Using variables for Function names...

I've called functions whose names where in string variables:
strVar = "Now()"
MsgBox Eval(strVar)

?eval("now()")
4/16/98 12:28:39


Quote:
>  Maybe I'm off base here but I was trying to use a variable to represent a
>function name in a Call statement.

>  Here's the original:
>            Call SomeFunction(argument1, argument2)

>  Here's what I tried:
>            Dim SomeVariable as Variant
>            SomeVariable = "SomeFunction"
>            Call SomeVariable(argument1, argument2)

>  It bombs out. Every different variable type I've tried also bombs out. Do I
>have the syntax wrong? Am I trying something that is impossible? Any advice
>would be welcome -- Thanks in advance.

>  TimK

--
Access FAQ list (in no particular order):
http://home.att.net/~dashish
http://www.hammerdata.com/Newsgrp/
http://odyssey.apana.org.au/~abrowne/
http://www.trevor.easynet.co.uk
http://www.channel1.com/users/rogue/Access/
http://www.iol.ie/~moshea/access.htm
http://search.dejanews.com/dnquery.xp?QRY=&ST=PS&DBS=1&defaultOp=AND&...
http://search.microsoft.com/searchbin/kb/mts.idq?D=access+or+vbapps&A..."frequently+asked+questions"&O="frequently+asked+questions"&MSCOM_SRV=http://www.microsoft.com


Mon, 02 Oct 2000 03:00:00 GMT  
 Help -- Using variables for Function names...

Try Eval().

A word of warning though: Access cannot perform the normal
syntax checking on a string passed to Eval(), so you can crash
the program. If you are a careful developer, you may like to
check the string you are passing has been properly created
before passing it to Eval().

Quote:

>   Maybe I'm off base here but I was trying to use a variable to represent a
> function name in a Call statement.

>   Here's the original:
>             Call SomeFunction(argument1, argument2)

>   Here's what I tried:
>             Dim SomeVariable as Variant
>             SomeVariable = "SomeFunction"
>             Call SomeVariable(argument1, argument2)

>   It bombs out. Every different variable type I've tried also bombs out. Do I
> have the syntax wrong? Am I trying something that is impossible? Any advice
> would be welcome -- Thanks in advance.

  ,~,_/\
 /      \   Allen Browne
{ Perth  }  Australia
 *_,~~\_/   http://odyssey.apana.org.au/~abrowne/
       v


Tue, 03 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help with using names and variables in a function call

2. using variable names in VBA Range function

3. using a variable to specify field name in dlookup function

4. Call Function using Func Name stored in variable

5. Using a variable to increment a variable name.

6. Help Using Variable To Call a Procedure or function

7. Naming convention for seriescollection(arg).name using a string variable

8. shorten form name in code by using variable set to the name of the form

9. Using a variable for a Path Name and File Name in a cell reference

10. Help!! Need variable name from other variables


 
Powered by phpBB® Forum Software © phpBB Group