ACC: DAO Version Property Returns "3.0" for Jet 3.5 DatabasesID: Q171192
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
The DAO Version property of a Microsoft Jet 3.5 database object in a
Microsoft Jet workspace returns "3.0" even though the DAO Version property
of the DBEngine object returns "3.5."
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR
OWN RISK. Microsoft provides this code "as is" without warranty of any
kind, either express or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to your version of the
"Building Applications with Microsoft Access" manual.
The DAO Version property returns the version of Microsoft Jet that created the database. The Microsoft Jet database file format did not change from Microsoft Jet 3.0 to 3.5; therefore, the Version property always "3.0".
Because the Version property of DAO cannot distinguish between databases
created with Microsoft Jet 3.0 and Microsoft Jet 3.5, you can determine
which version of Microsoft Jet created the database by determining which
version of Microsoft Access was used to create or convert the database. To
determine which version of Microsoft Access created the database, you can
use the AccessVersion property.
NOTE: The AccessVersion property is unsupported and subject to change in
future releases of Microsoft Access.
The AccessVersion property is not a native Microsoft Jet property, but an
application property specific to Microsoft Access. Therefore, this property
will only exist if you have opened the database at least once in Microsoft
Access version 2.0 or later.
For a Microsoft Access 2.0 database, the AccessVersion property returns
"02.00". For a Microsoft Access 7.0 database, the AccessVersion property
returns a string that always begins with "06" followed by a period and two
digits. For a Microsoft Access 97 database, the AccessVersion property
returns a string that always begins with "07" followed by a period and two
digits.
In both Microsoft Access 7.0 and 97, the final two digits returned by the
AccessVersion property may vary depending on the dynamic-link library (DLL)
that was used to create the database's Visual Basic for Applications
project. Therefore, your code should ignore the final two digits if you
want to determine the version that created or converted the database. The
following function returns the version of Microsoft Access used to create
or convert a database by examining only the first two digits returned for
the AccessVersion property. This function takes a String argument that
specifies the path to the database.
Option Explicit
Function FindVersion(strDbPath As String) As String
Dim dbs As Database
Dim strVersion As String
Const conPropertyNotFound As Integer = 3270
On Error GoTo Err_FindVersion
' Open the database and return a reference to it.
Set dbs = OpenDatabase(strDbPath)
' Check the value of the AccessVersion property.
strVersion = dbs.Properties("AccessVersion")
' Return the two leftmost digits of the value of
' the AccessVersion property.
strVersion = Left(strVersion, 2)
' Based on the value of the AccessVersion property,
' return a string indicating the version of Microsoft Access
' used to create or open the database.
Select Case strVersion
Case "02"
FindVersion = "2.0"
Case "06"
FindVersion = "7.0"
Case "07"
FindVersion = "8.0"
End Select
Exit_FindVersion:
On Error Resume Next
dbs.Close
Set dbs = Nothing
Exit Function
Err_FindVersion:
If Err.Number = conPropertyNotFound Then
MsgBox "This database hasn't previously been opened " & _
"with Microsoft Access."
Else
MsgBox "Error: " & Err & vbCrLf & Err.Description
End If
Resume Exit_FindVersion
End Function
This behavior is by design.
This behavior does not occur with a database object in an ODBCDirect workspace; in that case, the Version property returns the version of the ODBC driver rather than the version of Microsoft Jet.
?DBEngine.Version
For more information about the Version property, search the Help Index for "Version property."
Keywords : kbcode MdlDao
Version : 7.0 97
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: April 22, 1999