473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 1974
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: schaf | last post by:
Hi ! I'm writing a new xsl:function, which uses two other functions. But by the call of the first function, it would be abort just after the call. Not even the xsl:param would be set. I don't...
5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
3
by: PiGei | last post by:
Hi all, I'm trying to build a function that - providing the dbname and the query name - show the results. I don't know how to solve this problem... when I try to insert the variable into this...
5
by: Matt Clepper | last post by:
Any way to do this? I need to call functions based on a variable. Do I actually have to make a case statement and call each funciton explicitly, or is there any way to call a function where the...
5
by: Rob | last post by:
Help me, I'm just beginning with programming in Access 2000. I've tried the http://www.mvps.org/access/api/api0001.htm but it won't work in Access. What am i doing wrong. I don't have...
24
by: ALI-R | last post by:
Hi All, First of all I think this is gonna be one of those threads :-) since I have bunch of questions which make this very controversial:-0) Ok,Let's see: I was reading an article that When...
5
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
7
by: Steve_Black | last post by:
Hello, I'm toying with the idea of loading a MenuStrip (VB.Net 2005) dynamically based on who is logged into my system. Every user has different security settings and I want to customize the...
0
by: mix01 | last post by:
Hi, I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help. Many thanks, Mix01 Version of the program
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.