Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running MS Access functions from Visual Basic 6

Status
Not open for further replies.

gnarus

Programmer
Jan 24, 2002
6
US
I am attempting to access a function from VB 6 that returns a string within an MS Access module. I am getting nowhere with the syntax that I assumed to be:
"mystring = dba.DoCmd.OpenModule(modname, procname)"

I have proven that dba is there by getting the tabledefs count and the querydefs count by opening the database via the currentdatabase method.

However the dba.Modules.Count is 0 presumably because no module is running. Is there any way this can be done?
 
The 'normal' approach to use VBA modules in a foregin .mdb
is to include the .mdb as a reference. This works nicely from one .ndb to the next / other. I haven't tried it from VB, but the same principal should work. Using this approach, ONLY the procedures in MODULES are available (no forms/tables/queries/reports) you can still reference recordset objects via the dim / set functions.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
On the other hand, if you then COMPILE the VB project (with the .MDB as a referenced object), you should (in theory?) end up with the .MDB included in the compilation. Hmmmmmmmmmmmm, BAD idea.


You could -of course- just copy the necessary functions into the VB project as a (seperate) module.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Perhaps I wasn't clear...

We all know that MS Access is limited in that one cannot write stored procedures, rules, or triggers. I was hoping to overcome this limitation by writing functions in modules in MS Access that would behave like stored procedures that could be called from clients running applications written with VB6.

My question is 1) Is this possible? and 2) If so, what is the syntax assuming I have instantiated the Access Application object?

Referencing the MDB from another MDB is no help and neither is copying the module from the MDB to the App.
 
Hmmmmmmmmmmm,

IMHO, it mostly depends on your deffinition(s). AFAIK there is no (pratical) way to extract data from the tables of an .MDB file w/o instantiation of the Jet db engine. To me this says (briefly) tge answere id "no". You can (probably) as I noted earlier add the .MDB file as a reference in the VB program, and execute the CODE / MODULE from VB. Any use of tables / queries in that code will either fail or (possibly) instantiate the Jet db engine. You CAN (obviously) instantiate the Jet engine with the appropiate declarations and write SQL queries aginst the instantiated workspace / database. But -IMHO- this does not overcome any 'limitation', it just moves some of the pieces between the various objects. The Jet db engine is a LOCAL process. It ALWAYS returns the entire recordset to the LOCAL engine for processing. That bding said, the process appears to be quite good a cacheing data from tables, so the overhead (at least within Ms. A.) of runnning queries is not as bad as might be assumed - but of course that depends on some careful instantiation of the Jet engine (A.K.A. MDB), so you are not creating (and re-creating) seperate instantations for each query/results set.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top