VB6 into Access 97 mdb

R

rich

Hi,

using vb6, I am connecting to an Access 97 using

set dbs = dbEngine.workspace(0).Opendatabase("c:\myDb.mdb)


All works well however the user gets a blank Access session in the
background. Due to the nature of the app I cannot use bound controls.
Can anybody explain why this access session keeps showing up? Very
annoying as it will not go away even if I do dbs.close and Set DBS = Not
until the app close will it go away.

Rich
 
M

MacDermott

If all you're using from the Access 97 mdb is the data, I'd suggest using
ADO instead of DAO.

HTH
- Turtle
 
D

david epsom dot com dot au

That line does not, by itself, open a copy of Access.

If your program opens a copy of Access, it is because
of something else you are doing, possibly even the
way you are declaring and creating some other object.

(david)
 
R

rich

Hmmm,

So some other rogue Class Module is initialising an Access seesion -
will check out, thanks

Rich
 
R

rich

Davis,

Stepping thru on debug, it does, as soon as that line executes an Access
session open (however no database is shown) and it cannot be closed
until the user closes the .exe.

Rich
 
M

MacDermott

If you really need to have an opendatabase() object, you might be happier
explicitly creating a named instance of Access, which you can explicitly
quit later.

I'm still quite curious as to what you're doing that you need this
functionality...

- Turtle
 
R

rich

Turtle,

I am building an app sits on a variety of PCs that have either DAO or
ADO installed and I cannot upgrade the DAO machines to ADO, so I
therefore have to go at the lowest denominator (DAO). Using ADO is
fine, but some machines only have DAO and will not be upgraded for
another 9 months

Rich
 
D

david epsom dot com dot au

Stepping thru on debug, it does, as soon as that line executes an Access
session open (however no database is shown) and it cannot be closed

Presumably, this reflects the way you have declared your references
or objects.

What have you referenced and declared?

(david)
 
M

MacDermott

You can still use DAO without opening an instance of Access.
Include a DAO reference in your VB project.

Here's some code taken from the DAO Reference Help File:
Dim wrkJet As Workspace
Dim dbsNorthwind As Database
Dim prpLoop As Property

' Create Microsoft Jet Workspace object.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)

' Open Database object from saved Microsoft Jet database
' for exclusive use.
MsgBox "Opening Northwind..."
Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb", True)
MsgBox "OK"

When you see the OK msgbox, open your task manager - you'll see there's no
instance of Access.
(I'd suggest using a full file path for an existing .mdb file, instead
of Northwind.mdb)

HTH
- Turtle
 
Top