Solved

Dynamically load & execute VB function

Posted on 2003-10-28
7
581 Views
Last Modified: 2012-08-14
Hello,

I'm using MS Access for fast multi-thread web pages download  from the internet and save parsed results into database or files

I would like to create sort of profiles for each job
I need a way to setup number of functions like Start_Download() and Finalize_Download() for each profile

and I want to display profiles in drop-down menu, so once user select some profile and click "GO" button I want my program to call functions (Start_Download() and Finalize_Download()) of selected profile
and I want this functions to have access to few global variables.

I have tried to use separate modules for each profile

I can do something like "call Module1.Start_Download(parameters)" but for some reason I can't use something like
 call Me.Application.Modules("Module1").Start_Download(parameters) (it said function is not found)
and also Eval("Module1.Start_Download(parameters)") is not working.

I don't mind to  use Classes instead of functions as long as I can select class by name (programmatically) - if someone can give me an example of how to use nested classes in different modules

any idea on how to accomplish this?

I could use One module and modify this module with different programs for each profile stored in databases (or modules) but i don't want to do it because it will be hard to control & save future program modifications in this approach.


Any help is appriciated
0
Comment
Question by:DRY_GIN
  • 3
  • 3
7 Comments
 
LVL 26

Expert Comment

by:Alan Warren
Comment Utility
Hi DRY_GIN,

Is this an Access application or ASP?
Are you using the Access database just to store data or...?

Alan
0
 
LVL 3

Author Comment

by:DRY_GIN
Comment Utility
it's microsoft Access Application

I figure out some way to implement this, the only problem is that it seems to me it that Module1.function and Module2.fuction can not co-exist if they have the same name, so for now instead of it i'm using
module1.fucntion_1 , module2.fucntion_2 ...

and I'm calling functions as

Application.Run "function_" & i ,  some parameters

it is working quite well, still it's not a perfect solution because i need to rename same functions for each new profile.

0
 
LVL 11

Expert Comment

by:joekendall
Comment Utility
Are these functions in Access?

You can't have 2 functions named the same in Access. It doesn't accept Overloading so it doesn't know which function to call.

Why do you need to 2 different functions? Are they identical or are the different in some way? Can you post your code and maybe some changes could be made to make it work?

Joe
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Author Comment

by:DRY_GIN
Comment Utility
I have a package (big set of functions, objects and tables) to do some job (web page download) with timers data processing ect.
now I want to use it for the different purposes.

for example I want to download 100000 pages from web site one -and parse whose pages into database - this require some additional coding.
tomorrow let's say I want to download 20000 images from web site 2 - so it will be another set of small additional functions to process with this images

I want to store all this "additions"  somehow inside my program for later usage.

Each of this jobs has it's own set of 6 small functions

OnStart
OnStop
PrepareNewDownload
FinishDownload
OnError
OnTimeOut
this 6 functions are not identical from job to job

in my main package I want to Call functions related to selected job (selected profile) during the process


So question was how to store pieces of Visual Basic code for different jobs inside one MS Access application (MDB file)

to have ability to use it later.

And later on if I select let's say job N10  I need some how to Use this 6 functions of Job 10 WITHOUT nasty Select cases like

Select JobID
 case 1:
   call onStart1
case 2
 call onStart2
....  <--- ugly


I don't know how else to explain

0
 
LVL 11

Accepted Solution

by:
joekendall earned 250 total points
Comment Utility
I believe you have 3 choices. You already know about 2 of them.

1 - Use the Select Case statements
2 - Make different functions for each JobID
3 - You can insert VB code into a module in Access. You can look up information in the help file about the Module Object.

Joe
0
 
LVL 3

Author Comment

by:DRY_GIN
Comment Utility
I believe i already know about 3 of them.

" You can insert VB code into a module in Access" - did you read my question:
-"I could use One module and modify this module with different programs for each profile stored in databases (or modules) but i don't want to do it because it will be hard to control & save future program modifications in this approach
0
 
LVL 11

Expert Comment

by:joekendall
Comment Utility
If I missed that part, I am sorry.

Since you already know 3 different ways to do it, I guess I can't be of any help. Maybe Alan has some insights.

Joe
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now