Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/171192

From BetaArchive Wiki

Article ID: 171192

Article Last Modified on 1/20/2007



APPLIES TO

  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition



This article was previously published under Q171192

Advanced: Requires expert coding, interoperability, and multiuser skills.


SYMPTOMS

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.

CAUSE

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".

RESOLUTION

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.

  1. Start Microsoft Access 7.0 or 97.
  2. Open the sample database Northwind.mdb.
  3. Create a module and type the following line in the Declarations section if it is not already there:

          Option Explicit
                            
  4. Type the following procedure:

          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
                            
  5. To test this procedure, type the following into the Debug window, and then press ENTER:

    ?FindVersion("C:\Office97\Office\Samples\Northwind.mdb")

    Note that the function returns the version of Microsoft Access used to create the database.


STATUS

This behavior is by design.

MORE INFORMATION

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.

Steps to Reproduce Behavior


  1. Start Microsoft Access 97.
  2. Create a new, blank database.
  3. Press CTRL+G to open the Debug window.
  4. Type the following in the Debug window, and then press ENTER:


?CurrentDB.Version

Note that "3.0" is returned to the Debug window indicating the current database is a Microsoft Jet 3.0 database. However, "3.5" is returned to the Debug window if you type the following line:

?DBEngine.Version



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.

REFERENCES

For more information about the Version property, search the Help Index for "Version property."


Additional query words: jet 3 0 5

Keywords: kbcode kbprb KB171192