473,799 Members | 3,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_nam e
'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 16085
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_nam e
'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_nam e (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.spa m.cox.net> wrote in message
news:rg******** *************** *********@4ax.c om... 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_nam e
'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("MyFunctio n()")

-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_nam e (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.spa m.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_nam e
>'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.spa m.cox.net> wrote in message
news:g6******** *************** *********@4ax.c om...
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("MyFunctio n()")

-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_nam e (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.spa m.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_nam e
>'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
2965
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 p3); The parameters here can be read either in the forward order from p1 till p3 or reverse order from p3 till p1. Can anyone explain what is the advantage/disadvantage of either of
6
3314
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 in VBA from my other Access applications. This works fine and I'm quite happy with it... except for one area; error handling. In most of my functions I call an error handler which
14
3014
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() ' This method shows the form used to get the info If sWhereInt = "" Then DoCmd.OpenForm sFormNameInt, acNormal, , , acFormAdd, _
1
2914
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 written in C#. When the app calls my unmanaged functions, they work fine. But as soon as my unmanaged functions call managed functions (in the same source file!), the app reports an "unknown exception" error.
5
3444
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 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
2
3152
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 the stack pointer and it does it by the command "add esp,8" after returning from the called function. My questions: 1. Is the stack pointer common in a certain thread(or process)? 2. How does the called function get the parameters, is it by...
18
4361
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 can use dlopen/whatever to convert the function name into a pointer to that function, but actually calling it, with the right number of parameters, isn't easy. As far as I can see, there are only two solutions: 1) This one is portable. If...
15
22869
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 could either be f1() or f2(). BRs!
11
3203
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 Esa_Init. When I make a call, VS2005 reports "AccessViolationException" and refers to the 4th parameter (EsaT_State_Handle). I don't know how to define nor pass this reference correctly to the legacy DLL. What am I doing wrong? Thanks in...
16
517
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 and my c++ code should call c code.but when i tried to call a function in c code externing that function in my c++ code, i am getting unresolved external symbol error. Whatever i try its giving more and more errrors...so is it possible to merge 2...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.