OpenDatabase in Access 2000+ (delayed initialisation of dbEngine)

  • Thread starter david epsom dot com dot au
  • Start date
D

david epsom dot com dot au

In Access 2000+, if you do

OpenDatabase("c:\mydb")

as the first action after opening a database, it creates
a new dbEngine object, not using the workgroup/user
credentials from Access. If you have a secured database,
the OpenDatabase action fails. In contrast, this works:

Application.dbEngine.OpenDatabase("c:\mydb")

the dbEngine object inherits the security credentials
from Access startup.

I don't know if this is just 'delayed' initialisation of
the dbEngine object (in which case it will come good after
a time, and may be difficult to demonstrate), or if it
is 'On Demand' initialisation (in which case you always
need to perform some action to initialise the dbEngine
object from the Application object before using OpenDatabase).


I can't help but notice that it raises the possibility of
obscure coding strategies to deliberately initialise the
dbEngine object with different security credentials than
those used at startup! But I think that even without that
it may be the source of occasional obscure errors.

(david)
 
D

Dirk Goldgar

david epsom dot com dot au said:
In Access 2000+, if you do

OpenDatabase("c:\mydb")

as the first action after opening a database, it creates
a new dbEngine object, not using the workgroup/user
credentials from Access. If you have a secured database,
the OpenDatabase action fails. In contrast, this works:

Application.dbEngine.OpenDatabase("c:\mydb")

the dbEngine object inherits the security credentials
from Access startup.

I don't know if this is just 'delayed' initialisation of
the dbEngine object (in which case it will come good after
a time, and may be difficult to demonstrate), or if it
is 'On Demand' initialisation (in which case you always
need to perform some action to initialise the dbEngine
object from the Application object before using OpenDatabase).


I can't help but notice that it raises the possibility of
obscure coding strategies to deliberately initialise the
dbEngine object with different security credentials than
those used at startup! But I think that even without that
it may be the source of occasional obscure errors.

Very interesting, David. How did you come across this, and how did you
demonstrate the specifics? Was it a credential failure that tipped you
off?
 
D

david epsom dot com dot au

Dirk Goldgar said:
Very interesting, David. How did you come across this, and how did you
demonstrate the specifics? Was it a credential failure that tipped you
off?

It failed on conversion from A97, and it was different from
my personal coding practice (which uses fully qualified objects
in any startup code).

The rest is surmised from the (user permission) error message,
and the documented behaviour of OpenDatabase with an uninitialised
dbEngine object. Access is known to use Delay Loading of some
kind.

I guess it is a bit obscure: it only affected that application
because it uses Access Workgroup Security AND initialises a
database object for tbl.Seek.

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top