Solved

Dynamically load & execute VB function

Posted on 2003-10-28
7
587 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

828 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