Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Call a function where function name is a string

Posted on 2002-03-25
7
Medium Priority
?
350 Views
Last Modified: 2008-03-10
I want to be able to call functions.  The names are stored in a table.  I am looking up the name in the table using a dlookup.  When I get the name of the function, I try to call the function but it does not work.  I am using the Eval Function.  Code looks like this

dim strProgramCall as string

strProgramCall = Nz(DLookup("[ProgramCall]", "Report List", "[Report ID] = " & Me.Selected_Report), "None")
Eval(strProgramCall)

Error message says Run-time Error 2482 Clone Can't find the name 'NameOfFunction' you entered in the expression.

Yes, there is a function that is called NameOfFunction.  

Can I call a function this way?  What am I doing wrong?
0
Comment
Question by:LJ083198
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 2

Expert Comment

by:xtrahands
ID: 6895599
LJ

I don't have the answer but I do know what the problem is.

When you evaluate the function NameOfFunction the syntax is eval(NameOfFunction) not eval("NameOfFunction")

I tried to do something similar a while back but never managed to find the answer so good luck.

xtrahands
0
 
LVL 2

Expert Comment

by:xtrahands
ID: 6895608
LJ

I don't have the answer but I do know what the problem is.

When you evaluate the function NameOfFunction the syntax is eval(NameOfFunction) not eval("NameOfFunction")

I tried to do something similar a while back but never managed to find the answer so good luck.

xtrahands
0
 
LVL 2

Accepted Solution

by:
xtrahands earned 400 total points
ID: 6895609
LJ

I had another look at that database and I did get it to work.  My syntax was:

     If strProgramCall <> "" Then
        varX = Eval(strProgramCall & "()")
     End If

Give it a crack and see if it works.

xtrahands


0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Expert Comment

by:Syed Irtaza Ali
ID: 6895816
Well there is a way but for that u will need a form from where you want to call the function.

You will be using the OnTimer event and TimerInterval property for that form.

the code is

get the function name then

Form1.onTimer = "=" & strFunctionName & "()"
Form1.TimerInterval=1000 ''''' ie for 1 sec


try it and if u have any problem do mention.

Nomi.
0
 
LVL 2

Expert Comment

by:Syed Irtaza Ali
ID: 6895830
Give xtrahands the points. It damn works!
0
 
LVL 11

Expert Comment

by:joekendall
ID: 6896202
Here is a link that backs up what xtrahands wrote.

http://www.mvps.org/access/modules/mdl0002.htm

Thanks!

Joe
0
 

Author Comment

by:LJ083198
ID: 6897692
YOU ARE AWESOME
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question