I'm trying to determine what the version of DAO is and create an object
for it.


Code:
--------------------
version=<Version property found here>
Set objDAO = CreateObject("DAO.DBEngine." & version)
--------------------




--
djp
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Re: Dynamically Creating DAO Object by Bob

Bob
Wed May 09 20:08:31 CDT 2007

djp wrote:
> I'm trying to determine what the version of DAO is and create an
> object for it.
>
>
> Code:
> --------------------
> version=<Version property found here>
> Set objDAO = CreateObject("DAO.DBEngine." & version)
> --------------------

I don't remember. if nobody replies, take a look in Access online help. If
that does not help, try an Access newsgroup.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Dynamically Creating DAO Object by mr_unreliable

mr_unreliable
Thu May 10 16:40:30 CDT 2007

djp wrote:
> I'm trying to determine what the version of DAO is and create an object
> for it.

hi djp,

If all else fails, you can always use a "brute force" approach.

By that, I mean looking through your registry, and testing
for the presence of each candidate, until you get a failure
(meaning that the version previous to the failure is present
-- while the version causing the failure is not).

Here is a sample script. In my (ancient) system, there are
only two DBEngines present, versions 35 & 36. And so, this
script fails when I try to read up version 37.

--- <snip> ---

Set WshShell = WScript.CreateObject("WScript.Shell")

bKey = WshShell.RegRead("HKCR\DAO.DBEngine.35\")
msgbox(bKey)

bKey = WshShell.RegRead("HKCR\DAO.DBEngine.36\")
msgbox(bKey)

bKey = WshShell.RegRead("HKCR\DAO.DBEngine.37\")
msgbox(bKey)

--- </snip> ---

Unfortunately, afaik, regread has no direct way of telling
you that a key is not present, other than throwing an error.
And so, you are going to have to trap the error to determine
where the script fails, and by implication, the latest
version of the DBEngine.

Also unfortunately, vbScript does not have very sophisticated
methods of trapping errors, so you are going to have to use
ON ERROR RESUME NEXT, and test the error object each time.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)