473,382 Members | 1,615 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,382 software developers and data experts.

Calling sub and/or function

I have a possibly stupid question - thought it was simple to do....

From vba code I want to call a sub or function. The name of the sub/function
is stored in a table. I want to achieve something like this:

.....
rs.open, mytable, conn
'Here is the problem-line:
call rs!function_name
'And here should the sub/function run...

Probably I have to declare a variable, set its name to the function name and
execute the variable, but I can't figure it out...

Thanks :-)

Jon Ole Hedne
Norway
Nov 12 '05 #1
4 16070
On Sat, 17 Jan 2004 21:48:40 +0100, "Jon Ole Hedne"
<jo*****@online.no> wrote:

Check out the Eval function in the Help file.
-Tom.

I have a possibly stupid question - thought it was simple to do....

From vba code I want to call a sub or function. The name of the sub/function
is stored in a table. I want to achieve something like this:

....
rs.open, mytable, conn
'Here is the problem-line:
call rs!function_name
'And here should the sub/function run...

Probably I have to declare a variable, set its name to the function name and
execute the variable, but I can't figure it out...

Thanks :-)

Jon Ole Hedne
Norway


Nov 12 '05 #2
I have now. The Eval-function returns only the value of another function, it
doesn't actually run the function (or sub). One procedure could be something
like this:
Public Sub Etiketter()
Docmd.runSql "Select something..."
DoCmd.OpenForm "TheForm", acNormal
End Sub

Public Sub RunOnClick()
rs.open, mytable, conn
call rs!function_name (Which contains "Etiketter" Or "Etiketter()" Or
Etiketter)
The SQL should execute and the form should open.... Exit sub

Jon Ole

"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:rg********************************@4ax.com... On Sat, 17 Jan 2004 21:48:40 +0100, "Jon Ole Hedne"
<jo*****@online.no> wrote:

Check out the Eval function in the Help file.
-Tom.

I have a possibly stupid question - thought it was simple to do....

From vba code I want to call a sub or function. The name of the sub/functionis stored in a table. I want to achieve something like this:

....
rs.open, mytable, conn
'Here is the problem-line:
call rs!function_name
'And here should the sub/function run...

Probably I have to declare a variable, set its name to the function name andexecute the variable, but I can't figure it out...

Thanks :-)

Jon Ole Hedne
Norway

Nov 12 '05 #3
On Sun, 18 Jan 2004 01:14:07 +0100, "Jon Ole Hedne"
<jo*****@online.no> wrote:

Oh, yes it does.
Think about it. You're saying that the Eval function "only" returns
the value of another function. How do you think it computes the return
value? Of course by running that function!

Eval works only with functions, not with subs. Rewrite your subs as
functions.

Debug.Print Eval("MyFunction()")

-Tom.
I have now. The Eval-function returns only the value of another function, it
doesn't actually run the function (or sub). One procedure could be something
like this:
Public Sub Etiketter()
Docmd.runSql "Select something..."
DoCmd.OpenForm "TheForm", acNormal
End Sub

Public Sub RunOnClick()
rs.open, mytable, conn
call rs!function_name (Which contains "Etiketter" Or "Etiketter()" Or
Etiketter)
The SQL should execute and the form should open....

Exit sub

Jon Ole

"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:rg********************************@4ax.com.. .
On Sat, 17 Jan 2004 21:48:40 +0100, "Jon Ole Hedne"
<jo*****@online.no> wrote:

Check out the Eval function in the Help file.
-Tom.

>I have a possibly stupid question - thought it was simple to do....
>
>From vba code I want to call a sub or function. The name of thesub/function >is stored in a table. I want to achieve something like this:
>
>....
>rs.open, mytable, conn
>'Here is the problem-line:
>call rs!function_name
>'And here should the sub/function run...
>
>Probably I have to declare a variable, set its name to the function nameand >execute the variable, but I can't figure it out...
>
>Thanks :-)
>
>Jon Ole Hedne
>Norway
>


Nov 12 '05 #4
Of course ...:-) It works now - I had used wrong string-formatting in my
table ("MyProc()" instead of MyProc())... Thanks a lot for your help!

Jon Ole

"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:g6********************************@4ax.com...
On Sun, 18 Jan 2004 01:14:07 +0100, "Jon Ole Hedne"
<jo*****@online.no> wrote:

Oh, yes it does.
Think about it. You're saying that the Eval function "only" returns
the value of another function. How do you think it computes the return
value? Of course by running that function!

Eval works only with functions, not with subs. Rewrite your subs as
functions.

Debug.Print Eval("MyFunction()")

-Tom.
I have now. The Eval-function returns only the value of another function, itdoesn't actually run the function (or sub). One procedure could be somethinglike this:
Public Sub Etiketter()
Docmd.runSql "Select something..."
DoCmd.OpenForm "TheForm", acNormal
End Sub

Public Sub RunOnClick()
rs.open, mytable, conn
call rs!function_name (Which contains "Etiketter" Or "Etiketter()" Or
Etiketter)
The SQL should execute and the form should open....

Exit sub

Jon Ole

"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:rg********************************@4ax.com.. .
On Sat, 17 Jan 2004 21:48:40 +0100, "Jon Ole Hedne"
<jo*****@online.no> wrote:

Check out the Eval function in the Help file.
-Tom.
>I have a possibly stupid question - thought it was simple to do....
>
>From vba code I want to call a sub or function. The name of the

sub/function
>is stored in a table. I want to achieve something like this:
>
>....
>rs.open, mytable, conn
>'Here is the problem-line:
>call rs!function_name
>'And here should the sub/function run...
>
>Probably I have to declare a variable, set its name to the function
nameand
>execute the variable, but I can't figure it out...
>
>Thanks :-)
>
>Jon Ole Hedne
>Norway
>

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference...
14
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
2
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
11
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
16
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.