Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Calling a Function stored in a field


Message #1 by Omar Chaudry <OChaudry@b...> on Thu, 28 Nov 2002 11:38:25 -0000
Hi All

I have a function name stored in a table's field. How do I go about calling
it in code.

 

Example scenario follows:-

tblMethod

Fields: methodID, methodDesc, MethodFunction, FunctionParam

My function name is stored in MethodFunction, and I wish to call that
function when user selects the particular method from a list box.

 

Any ideas would be greatly appreciated.

Omar

 



  DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee.  Access to this
message by anyone else is unauthorised.  If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful.  Please immediately contact the sender if you have received this
message in error. Thank you.



Message #2 by "bwarehouse" <bwarehouse@y...> on Thu, 28 Nov 2002 05:23:27 -0700
you may want to put a select case function in the afterupdate event of the
list box..

SELECT CASE mylstbox

Case methodID
	FunctionA
Case methodDESC
	FunctionB
Case MethodFunction
	FunctionC
Case FunctionParam
	FunctionD
END SELECT


later,
bware

-----Original Message-----
From: Omar Chaudry [mailto:OChaudry@b...]
Sent: Thursday, November 28, 2002 4:38 AM
To: Access
Subject: [access] Calling a Function stored in a field


Hi All

I have a function name stored in a table's field. How do I go about calling
it in code.



Example scenario follows:-

tblMethod

Fields: methodID, methodDesc, MethodFunction, FunctionParam

My function name is stored in MethodFunction, and I wish to call that
function when user selects the particular method from a list box.



Any ideas would be greatly appreciated.

Omar





  DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee.  Access to this
message by anyone else is unauthorised.  If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful.  Please immediately contact the sender if you have received this
message in error. Thank you.






Message #3 by Omar Chaudry <OChaudry@b...> on Thu, 28 Nov 2002 12:41:07 -0000
Thanks bware,
Not sure if I explained myself properly though. I was after creating dynamic
VBA statements on the fly based on user selection sort of like creating SQL
strings and then running them through the docmd.runsql method. Anything
similar exist for VBA statements as well?
Looking forward to your response
Omar

-----Original Message-----
From: bwarehouse [mailto:bwarehouse@y...] 
Sent: 28 November 2002 12:23
To: Access
Subject: [access] RE: Calling a Function stored in a field

you may want to put a select case function in the afterupdate event of the
list box..

SELECT CASE mylstbox

Case methodID
	FunctionA
Case methodDESC
	FunctionB
Case MethodFunction
	FunctionC
Case FunctionParam
	FunctionD
END SELECT


later,
bware

-----Original Message-----
From: Omar Chaudry [mailto:OChaudry@b...]
Sent: Thursday, November 28, 2002 4:38 AM
To: Access
Subject: [access] Calling a Function stored in a field


Hi All

I have a function name stored in a table's field. How do I go about calling
it in code.



Example scenario follows:-

tblMethod

Fields: methodID, methodDesc, MethodFunction, FunctionParam

My function name is stored in MethodFunction, and I wish to call that
function when user selects the particular method from a list box.



Any ideas would be greatly appreciated.

Omar





  DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee.  Access to this
message by anyone else is unauthorised.  If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful.  Please immediately contact the sender if you have received this
message in error. Thank you.









  DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee.  Access to this
message by anyone else is unauthorised.  If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful.  Please immediately contact the sender if you have received this
message in error. Thank you.


Message #4 by "cdebiasio@t... on Thu, 28 Nov 2002 14:18:29 +0100 (CET)
Hi!

Unfortunately, you cannot, using straight VB. Actually it has a "CallByName" 
method, but, it has a different meaning. With VB .NET you can play some tricks 
using the Delegates, which operate as pointers to functions (this is actually 
what you need).

I have found no better method than issuing a Select Case with a clear decode:

Select case rs("MethodFunction")
   Case "Function1": Call Function1
   Case "Function3": Call Function3
     :
End Select

At least, it works, and it's pretty easy to maintain (also, notice that you 
cannot ANYWAY automatize this specific virtualization aspect, since 
a "database" is NOT aware of YOUR CODE anyway! Again, in .NET you can do more 
with System inspectors, which dig into source code).

HTH
    Claudio de Biasio
      Team 97 S.r.l.

Quoting Omar Chaudry <OChaudry@b...>:

> Hi All
> 
> I have a function name stored in a table's field. How do I go about
> calling
> it in code.
> 
>  
> 
> Example scenario follows:-
> 
> tblMethod
> 
> Fields: methodID, methodDesc, MethodFunction, FunctionParam
> 
> My function name is stored in MethodFunction, and I wish to call that
> function when user selects the particular method from a list box.
> 
>  
> 
> Any ideas would be greatly appreciated.
> 
> Omar
> 
>  
> 
> 
> 
>   DISCLAIMER: The information in this message is confidential and may
> be
> legally privileged. It is intended solely for the addressee.  Access to
> this
> message by anyone else is unauthorised.  If you are not the intended
> recipient, any disclosure, copying, or distribution of the message, or
> any
> action or omission taken by you in reliance on it, is prohibited and may
> be
> unlawful.  Please immediately contact the sender if you have received
> this
> message in error. Thank you.
> 
> 
> 
> 
> 
Message #5 by Omar Chaudry <OChaudry@b...> on Thu, 28 Nov 2002 13:36:54 -0000
Thanks Claudio & bware, shall give this is a whirl
Omar

-----Original Message-----
From: cdebiasio@t... [mailto:cdebiasio@t...] 
Sent: 28 November 2002 13:18
To: Access
Subject: [access] Re: Calling a Function stored in a field

Hi!

Unfortunately, you cannot, using straight VB. Actually it has a "CallByName"

method, but, it has a different meaning. With VB .NET you can play some
tricks 
using the Delegates, which operate as pointers to functions (this is
actually 
what you need).

I have found no better method than issuing a Select Case with a clear
decode:

Select case rs("MethodFunction")
   Case "Function1": Call Function1
   Case "Function3": Call Function3
     :
End Select

At least, it works, and it's pretty easy to maintain (also, notice that you 
cannot ANYWAY automatize this specific virtualization aspect, since 
a "database" is NOT aware of YOUR CODE anyway! Again, in .NET you can do
more 
with System inspectors, which dig into source code).

HTH
    Claudio de Biasio
      Team 97 S.r.l.

Quoting Omar Chaudry <OChaudry@b...>:

> Hi All
> 
> I have a function name stored in a table's field. How do I go about
> calling
> it in code.
> 
>  
> 
> Example scenario follows:-
> 
> tblMethod
> 
> Fields: methodID, methodDesc, MethodFunction, FunctionParam
> 
> My function name is stored in MethodFunction, and I wish to call that
> function when user selects the particular method from a list box.
> 
>  
> 
> Any ideas would be greatly appreciated.
> 
> Omar
> 
>  
> 
> 
> 
>   DISCLAIMER: The information in this message is confidential and may
> be
> legally privileged. It is intended solely for the addressee.  Access to
> this
> message by anyone else is unauthorised.  If you are not the intended
> recipient, any disclosure, copying, or distribution of the message, or
> any
> action or omission taken by you in reliance on it, is prohibited and may
> be
> unlawful.  Please immediately contact the sender if you have received
> this
> message in error. Thank you.
> 
> 
> 
> 
> 



  DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee.  Access to this
message by anyone else is unauthorised.  If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful.  Please immediately contact the sender if you have received this
message in error. Thank you.



  Return to Index