Solved

Dynamically load & execute VB function

Posted on 2003-10-28
7
583 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
ID: 9640310
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
ID: 9641123
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
ID: 9641599
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 3

Author Comment

by:DRY_GIN
ID: 9642399
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
ID: 9642947
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
ID: 9648978
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
ID: 9649407
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

911 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

21 Experts available now in Live!

Get 1:1 Help Now