469,950 Members | 1,432 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

how to call a function when name is in a variable

really tricky one here.

I want to be able to call a function but the function name is in a variable.
The code is a security module that is querying a table that stores names of
functions, forms, reports etc and what access certain groups have. forms,
reports etc work fine as I use

DoCmd.OpenForm objectToRunName

but how do I do it when "objectToRunName" has a function name?

Thanks for any help
Alan
Nov 13 '05 #1
12 1782
Alan,
Do you mean that your objectToRunName comes from a function?

Dim strObject as string
strObject=YourFunction()
DoCmd.OpenForm strObject

--
Hope this helps
Arno R
"Baldy" <Jo**@smith.com> schreef in bericht news:41**********@news.adelaide.pipenetworks.com.. .
really tricky one here.

I want to be able to call a function but the function name is in a variable. The code is a
security module that is querying a table that stores names of functions, forms, reports etc and
what access certain groups have. forms, reports etc work fine as I use

DoCmd.OpenForm objectToRunName

but how do I do it when "objectToRunName" has a function name?

Thanks for any help
Alan

Nov 13 '05 #2
Hi Arno

No

the value in objectToRunName is name of the function I want to run.

Thanks for your response
Alan

"Arno R" <ar****************@tiscali.nl> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
Alan,
Do you mean that your objectToRunName comes from a function?

Dim strObject as string
strObject=YourFunction()
DoCmd.OpenForm strObject

--
Hope this helps
Arno R
"Baldy" <Jo**@smith.com> schreef in bericht
news:41**********@news.adelaide.pipenetworks.com.. .
really tricky one here.

I want to be able to call a function but the function name is in a
variable. The code is a security module that is querying a table that
stores names of functions, forms, reports etc and what access certain
groups have. forms, reports etc work fine as I use

DoCmd.OpenForm objectToRunName

but how do I do it when "objectToRunName" has a function name?

Thanks for any help
Alan


Nov 13 '05 #3
On Thu, 7 Oct 2004 21:54:39 +0930, "Baldy" <Jo**@smith.com> wrote:
Hi Arno

No

the value in objectToRunName is name of the function I want to run.

Thanks for your response
Alan

Hi
I have done this in vb6 but forgotten how.
However I see in the access97 help file (useful things) it says:

You can use the Eval function to evaluate an expression that results
in a text string or a numeric value.
You can construct a string and then pass it to the Eval function as if
the string were an actual expression. The Eval function evaluates the
string expression and returns its value. For example, Eval("1 + 1")
returns 2.
If you pass to the Eval function a string that contains the name of a
function, the Eval function returns the return value of the function.
For example, Eval("Chr$(65)") returns "A".
David

Nov 13 '05 #4
Try:

Application.Run ObjectToRunName

Tom
"Baldy" <Jo**@smith.com> wrote in message news:<41**********@news.adelaide.pipenetworks.com> ...
Hi Arno

No

the value in objectToRunName is name of the function I want to run.

Thanks for your response
Alan

"Arno R" <ar****************@tiscali.nl> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
Alan,
Do you mean that your objectToRunName comes from a function?

Dim strObject as string
strObject=YourFunction()
DoCmd.OpenForm strObject

--
Hope this helps
Arno R
"Baldy" <Jo**@smith.com> schreef in bericht
news:41**********@news.adelaide.pipenetworks.com.. .
really tricky one here.

I want to be able to call a function but the function name is in a
variable. The code is a security module that is querying a table that
stores names of functions, forms, reports etc and what access certain
groups have. forms, reports etc work fine as I use

DoCmd.OpenForm objectToRunName

but how do I do it when "objectToRunName" has a function name?

Thanks for any help
Alan


Nov 13 '05 #5
What data type is your variable? I'm having a hard time trying to
figure out why you're doing it this way.

If this has something to do with security and access control, why not
just wrap the function call around an if statement?

if certainGroupsHaveAccess then
call accessGranted()
else
call accessDenied()
end if
"Baldy" <Jo**@smith.com> wrote in message news:<41**********@news.adelaide.pipenetworks.com> ...
Hi Arno

No

the value in objectToRunName is name of the function I want to run.

Thanks for your response
Alan

"Arno R" <ar****************@tiscali.nl> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
Alan,
Do you mean that your objectToRunName comes from a function?

Dim strObject as string
strObject=YourFunction()
DoCmd.OpenForm strObject

--
Hope this helps
Arno R
"Baldy" <Jo**@smith.com> schreef in bericht
news:41**********@news.adelaide.pipenetworks.com.. .
really tricky one here.

I want to be able to call a function but the function name is in a
variable. The code is a security module that is querying a table that
stores names of functions, forms, reports etc and what access certain
groups have. forms, reports etc work fine as I use

DoCmd.OpenForm objectToRunName

but how do I do it when "objectToRunName" has a function name?

Thanks for any help
Alan


Nov 13 '05 #6
David you are a true legend that is exactly what I want and it works a
treat.
Thanks
Alan

"David Schofield" <d.***************@blueyonder.co.uk> wrote in message
news:41656cb3.1096326@localhost...
On Thu, 7 Oct 2004 21:54:39 +0930, "Baldy" <Jo**@smith.com> wrote:
Hi Arno

No

the value in objectToRunName is name of the function I want to run.

Thanks for your response
Alan

Hi
I have done this in vb6 but forgotten how.
However I see in the access97 help file (useful things) it says:

You can use the Eval function to evaluate an expression that results
in a text string or a numeric value.
You can construct a string and then pass it to the Eval function as if
the string were an actual expression. The Eval function evaluates the
string expression and returns its value. For example, Eval("1 + 1")
returns 2.
If you pass to the Eval function a string that contains the name of a
function, the Eval function returns the return value of the function.
For example, Eval("Chr$(65)") returns "A".
David

Nov 13 '05 #7
Thanks Tom you are also a legend.

Both yours and Davids solutions work.

Alan
"Tom Mitchell" <rt*****@swbell.net> wrote in message
news:70**************************@posting.google.c om...
Try:

Application.Run ObjectToRunName

Tom
"Baldy" <Jo**@smith.com> wrote in message
news:<41**********@news.adelaide.pipenetworks.com> ...
Hi Arno

No

the value in objectToRunName is name of the function I want to run.

Thanks for your response
Alan

"Arno R" <ar****************@tiscali.nl> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
> Alan,
> Do you mean that your objectToRunName comes from a function?
>
> Dim strObject as string
> strObject=YourFunction()
> DoCmd.OpenForm strObject
>
> --
> Hope this helps
> Arno R
>
>
> "Baldy" <Jo**@smith.com> schreef in bericht
> news:41**********@news.adelaide.pipenetworks.com.. .
>> really tricky one here.
>>
>> I want to be able to call a function but the function name is in a
>> variable. The code is a security module that is querying a table that
>> stores names of functions, forms, reports etc and what access certain
>> groups have. forms, reports etc work fine as I use
>>
>> DoCmd.OpenForm objectToRunName
>>
>> but how do I do it when "objectToRunName" has a function name?
>>
>> Thanks for any help
>> Alan
>>
>>
>
>

Nov 13 '05 #8
Thanks but the problem is there could be thousands of condiftions as the
function being run's name is coming from a table and I need to be able to
add new names without re-writting the code.

Thanks but Tom and David actually had the solution.
Alan

"user_5701" <us*******@hotmail.com> wrote in message
news:f1**************************@posting.google.c om...
What data type is your variable? I'm having a hard time trying to
figure out why you're doing it this way.

If this has something to do with security and access control, why not
just wrap the function call around an if statement?

if certainGroupsHaveAccess then
call accessGranted()
else
call accessDenied()
end if
"Baldy" <Jo**@smith.com> wrote in message
news:<41**********@news.adelaide.pipenetworks.com> ...
Hi Arno

No

the value in objectToRunName is name of the function I want to run.

Thanks for your response
Alan

"Arno R" <ar****************@tiscali.nl> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
> Alan,
> Do you mean that your objectToRunName comes from a function?
>
> Dim strObject as string
> strObject=YourFunction()
> DoCmd.OpenForm strObject
>
> --
> Hope this helps
> Arno R
>
>
> "Baldy" <Jo**@smith.com> schreef in bericht
> news:41**********@news.adelaide.pipenetworks.com.. .
>> really tricky one here.
>>
>> I want to be able to call a function but the function name is in a
>> variable. The code is a security module that is querying a table that
>> stores names of functions, forms, reports etc and what access certain
>> groups have. forms, reports etc work fine as I use
>>
>> DoCmd.OpenForm objectToRunName
>>
>> but how do I do it when "objectToRunName" has a function name?
>>
>> Thanks for any help
>> Alan
>>
>>
>
>

Nov 13 '05 #9
"Baldy" <Jo**@smith.com> wrote in news:4165ae71$1_1
@news.adelaide.pipenetworks.com:
Thanks but the problem is there could be thousands of condiftions as the
function being run's name is coming from a table and I need to be able to
add new names without re-writting the code.

Thanks but Tom and David actually had the solution.


This is utter bunk. User_9999 gave you some good advice. Although Microsoft
seems happy in confusing data and instructions it is a very bad idea to do
so.

BTW no one becomes a legend because he or she knows some trivial bit of code.

--
Lyle
--
use iso date format: yyyy-mm-dd
http://www.w3.org/QA/Tips/iso-date
--
The e-mail address isn't, but you could use it to find one.
Nov 13 '05 #10
Sorry I had no intent to upset yo and I do appreciate your time and effort
to respond however sometimes a little bit of information is what is needed
and in this case they had it although I do appreciate that you have a very
valid point.

Again, my appologies if I have casue you some distress, this was never my
intent.

Alan
"Lyle Fairfield" <Lo******@FFDBA.Com> wrote in message
news:Xn******************@130.133.1.4...
"Baldy" <Jo**@smith.com> wrote in news:4165ae71$1_1
@news.adelaide.pipenetworks.com:
Thanks but the problem is there could be thousands of condiftions as the
function being run's name is coming from a table and I need to be able to
add new names without re-writting the code.

Thanks but Tom and David actually had the solution.


This is utter bunk. User_9999 gave you some good advice. Although
Microsoft
seems happy in confusing data and instructions it is a very bad idea to do
so.

BTW no one becomes a legend because he or she knows some trivial bit of
code.

--
Lyle
--
use iso date format: yyyy-mm-dd
http://www.w3.org/QA/Tips/iso-date
--
The e-mail address isn't, but you could use it to find one.

Nov 13 '05 #11
Lyle:

Please clarify your statement regarding data and instructions. You
seem to be saying it is never appropriate to use a table to store a
list of functions and criteria under which they are to be run.

And I would agree I am not a legend, except perhaps in my own mind
;-)

Tom
Lyle Fairfield <Lo******@FFDBA.Com> wrote in message news:<Xn******************@130.133.1.4>...
"Baldy" <Jo**@smith.com> wrote in news:4165ae71$1_1
@news.adelaide.pipenetworks.com:
Thanks but the problem is there could be thousands of condiftions as the
function being run's name is coming from a table and I need to be able to
add new names without re-writting the code.

Thanks but Tom and David actually had the solution.


This is utter bunk. User_9999 gave you some good advice. Although Microsoft
seems happy in confusing data and instructions it is a very bad idea to do
so.

BTW no one becomes a legend because he or she knows some trivial bit of code.

--
Lyle
--
use iso date format: yyyy-mm-dd
http://www.w3.org/QA/Tips/iso-date

Nov 13 '05 #12
rt*****@swbell.net (Tom Mitchell) wrote in
news:70**************************@posting.google.c om:
Lyle:

Please clarify your statement regarding data and instructions. You
seem to be saying it is never appropriate to use a table to store a
list of functions and criteria under which they are to be run.

And I would agree I am not a legend, except perhaps in my own mind
;-)

Tom
Lyle Fairfield <Lo******@FFDBA.Com> wrote in message
news:<Xn******************@130.133.1.4>...
"Baldy" <Jo**@smith.com> wrote in news:4165ae71$1_1
@news.adelaide.pipenetworks.com:
> Thanks but the problem is there could be thousands of condiftions as
> the function being run's name is coming from a table and I need to be
> able to add new names without re-writting the code.
>
> Thanks but Tom and David actually had the solution.


This is utter bunk. User_9999 gave you some good advice. Although
Microsoft seems happy in confusing data and instructions it is a very
bad idea to do so.

BTW no one becomes a legend because he or she knows some trivial bit of
code.

--
Lyle
--
use iso date format: yyyy-mm-dd
http://www.w3.org/QA/Tips/iso-date


hardly ever ...

--
Lyle
--
use iso date format: yyyy-mm-dd
http://www.w3.org/QA/Tips/iso-date
--
The e-mail address isn't, but you could use it to find one.
Nov 13 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

By using this site, you agree to our Privacy Policy and Terms of Use.