Get version of Access for each db

ghudson

Registered User.
Local time
Today, 11:49
Joined
Jun 8, 2002
Messages
6,193
How can I get the version of Access a db was designed in from a listing of databases? My "tblFiles" table has a field named "FileInfo" that stores the location [\\drive\path\name.mdb] of the db's. My code below gets the version of Jet (3, 4, etc.) for each db but I need to externally get the true version of Access (8.0, 11.0, etc.) that each db was designed in.

Code:
Public Function VerifyJetVersion()
On Error GoTo Err_VerifyJetVersion
    
    Dim DB As DAO.Database
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim wrkJet As Workspace
	
    Set DB = CurrentDb
    Set rst = DB.OpenRecordset("tblFiles", dbOpenDynaset)
    Set wrkJet = CreateWorkspace("NewJetWorkspace", "admin", "", dbUseJet)
	
    rst.MoveFirst
	
    Do Until rst.EOF
        Set dbs = wrkJet.OpenDatabase(rst!FileInfo)
        rst.Edit
        rst!dbVersion = dbs.Version 'Version of Jet
        rst.Update
        dbs.Close
        rst.MoveNext
        Loop
    
    rst.Close
    DB.Close
    wrkJet.Close
	
Exit_VerifyJetVersion:
    Exit Function
	
Err_VerifyJetVersion:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_VerifyJetVersion
	
End Function
Thanks in advance for your help!
 
Thanks for the code Pat. I created a db to use your code as-is and I can only get the version of Access for the actual computer that I run it on when I run the ReferenceProperties() sub. Even though I have replaced the strDatabase with a location to a db that is older than the version of Access installed...the code is referencing the .OLB file for the computer and I can not see what I need to change so that I can grab the version of Access that the "strDatabase" was created in. Can that be done? I have included the db I created with your code. Thanks!
 

Attachments

Thanks to Rob for his help. Below is what I ended up using. The .Properties("AccessVersion") allows me to accurately grab the Access version that the database file was designed in.
Code:
    Dim db As DAO.Database
    Dim dbs As DAO.Database
    Dim rs As DAO.Recordset
    Dim wrkJet As Workspace
    
    Set db = CurrentDb
    Set rs = db.OpenRecordset("tblFiles", dbOpenDynaset)
    Set wrkJet = CreateWorkspace("NewJetWorkspace", "admin", "", dbUseJet)
    
    rs.MoveFirst
    
    Do Until rs.EOF
        Set dbs = wrkJet.OpenDatabase(rs!FileInfo)
        rs.Edit
        rs!AccessVersionNumber = dbs.Properties("AccessVersion") 'Version of Access for each db scanned
        rs!JetVersionNumber = dbs.Version 'Version of Jet for each db scanned
        rs.Update
        dbs.Close
        rs.MoveNext
        Loop
    
    rs.Close
    db.Close
    wrkJet.Close
Interestingly enough, the actual version numbers that I am getting from the code is different that what is publicly defined for each version of Access. Here is what the code is reporting...

Version 02.00 for Access 2.0
Version 06.68 for Access 95
Version 07.53 for Access 97 (8.0)
Version 08.50 for Access 2000 (9.0)
Version 09.50 for Access 2002/2003 (10.0/11.0)

If anybody else gets any different Access version numbers with their results I would be interested for you to post your results.
 
Sorry for Necro-post, but I've found some additional information on this.

Database.Properties("AccessVersion") returns the .mdb Access file version. For example, I'm using Access 2002, but my .mdb is saved in Access 2000 compatibility mode, so "AccessVersion" is 8.5, not the expected 9.5 for 2002.

Just in case anyone else has/had thoughts on this.
 

Users who are viewing this thread

Back
Top Bottom