Click to See Complete Forum and Search --> : CreateObject with DAO.DBEngine fails without explicit version number


Liam Elliott
July 5th, 2001, 04:15 AM
Hi gurus,

Hopefully this will be a simple one...

I'm trying to create an Access Database object using VBScript.
(I've also tried this from Excel VBA and I have the same problem...)

I have Excel, Access ect (Office 97) correctly installed on my machine.

My call to CreateObject("DAO.DBEngine") fails with "ActiveX component can't create object".
HOWEVER
a call to CreateObject("DAO.DBEngine.36") succeeds (i.e. explicitly stating the version).

Ideally I'd like to just use the latest installed version of Access by not having to
specify the actual version.

Looking in my registry there doesn't appear to be a "DAO.DBEngine" entry with
a "CurVer" key; unlike other of the office suite for example "Excel.Application.8" and
the entry "Excel.Application" whose current version points to "Excel.Application.8"

Is this the standard way that Access gets installed?
If not, how can I alter the way Access gets installed to ensure the "Current Version"
option is there?
Is there some reason that there can't be a "Current version" option?

Many Thanks,

Liam

Cakkie
July 5th, 2001, 04:47 AM
Well, this is a tough one,

DAO.DBEngine always reffers to DAO 3.0, so if you use it in a createobject, and DAO 3.0 isn't installed, it will fail.
This is because since office 97 came out, they changed the name of the object from DAO.DBEngine to DAO.DBEngine.35, so your not really passing a version, you're just passing the complete name.
DAO.DBEngine.35 probably reffers to DAO.DBEngine.35.0 or something like that.

Microsoft recommends not to use DAO.DBEngine in a createobject, but rather to add a refference to it (which is quite hard in VBScript don't you think).
On the other hand, when using Access or Excel (read as VBA), you have an object called DBEngine, which points to the default engine. This object has a version property, which you can use to determine the version of DAO used. Again, not possible from VBScript.

The only thing you can do is to check for the existance of the dll. The dll's should be located in C:\Program Files\Common Files\Microsoft Shared\DAO\
The dll's to look for are:
dao3032.dll for 3.0
dao350.dll for 3.5
dao360.dll for 3.6

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook