Re: How to determine an Access DB's file format

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Tim wrote:
Oh well, will have to redefine the expectations some. :-) Thx.

I have looked in the MS Acces Dev forum but found nothing related to this specifically.

I just ran across this looking for something else. Allen Browne posted this on his site at http://allenbrowne.com/ser-53code.html (Code for Splash screen with version information):



' Purpose: Return the file format of the database.
' Argument: The database to examine. Current database if nothing passed in.
' Return: Sales version number and file type, e.g.:
' "97 MDE", "2000 MDB", "2002/3 ADP", "2007 ACCDB".
' Zero-length string on error.
' Requires: Access 97 through 2007.
Public Function GetFileFormat(Optional db As DAO.Database) As String
On Error GoTo Err_Handler

Dim bResetDb As Boolean
Dim bIsCompiledOnly As Boolean
Dim bIsProject As Boolean
Dim strReturn As String

' If no database variable was passed in, use the
' current database and flag to clear it.
If db Is Nothing Then
bResetDb = True
Set db = DBEngine(0)(0)
End If

' Examine the Data Format version. The final character will be determined later.
' (We don't use CurrentProject.FileFormat - it's not in Access 2000.)
Select Case Int(Val(db.Version))
' Access 97 file format is 3.0
Case 3
strReturn = "97 MD"

' Access 2000 or 2002/3 file format is 4.0
Case 4
' Examine the Project Storage version to distinguish 2000 from 2002/3.
Select Case db.Properties("AccessVersion")
Case "08.50" ' 2000 format.
strReturn = "2000"
Case "09.50" ' 2002/3 fomat.
strReturn = "2002/3"
End Select

' Test the ProjectType to see if it's an MDB or ADP.
' Eval() lets this compile in Access 97.
If strReturn <> vbNullString Then
bIsProject = Eval("(CurrentProject.ProjectType = 1)")
If bIsProject Then
strReturn = strReturn & " AD"
Else
strReturn = strReturn & " MD"
End If
End If

' Access 2007 (accdb) file format is 12.0
Case 12
strReturn = "2007 ACCD"
End Select

' Now determine if the final character is B (as in MDB), or E (as in MDE.)
bIsCompiledOnly = (db.Properties("MDE") = "T")
If bIsCompiledOnly Then
strReturn = strReturn & "E"
Else
strReturn = strReturn & "B"
End If

' Determine if the runtime extension is used.
If db.name Like "*.ACCDR" Then
strReturn = strReturn & " (runtime)"
End If

' Return value.
If strReturn <> vbNullString Then
GetFileFormat = strReturn
End If

Exit_Handler:
' Dereference the database variable unless it was passed in.
On Error Resume Next

If bResetDb Then
Set db = Nothing
End If

Exit Function

Err_Handler:
Select Case Err.Number
Case 2482&, 3270& 'Object wasn't found (the Eval()). Property doesn't exist.
Resume Next
Case Else
Call LogError(Err.Number, Err.Description, conMod & ".GetFileFormat")
Resume Exit_Handler
End Select

End Function



--
---------------
John Mishefske, Microsoft Access MVP
.



Relevant Pages

  • Re: dao.property fld.Properties Values
    ... Dim tdf As DAO.TableDef ... Dim fld As DAO.Field ... Function GetDescripAs String ... Dim strReturn As String 'Name to return ...
    (microsoft.public.access.modulesdaovba)
  • Re: dao.property fld.Properties Values
    ... Dim tdf As DAO.TableDef ... Dim fld As DAO.Field ... Function GetDescripAs String ... Dim strReturn As String 'Name to return ...
    (microsoft.public.access.modulesdaovba)
  • Re: Extracting Data from Composite Field
    ... Function libUnravel(strDesc As String, ByVal n As Integer) As Variant ... Dim varElements As Variant ... Dim strReturn As String ... If lngPos> 0 And lngPos < Len) Then ...
    (comp.databases.ms-access)
  • RE: Undefined Function error - Complex
    ... "Clifford Bass" wrote: ... I see that you have "fGetCaseType = strReturn" at the end, ... Dim iPos1 As Long ... Dim strReturn As String ...
    (microsoft.public.access.queries)
  • RE: Undefined Function error - Complex
    ... I see that you have "fGetCaseType = strReturn" at the end, ... If it is in a form or report module, the query tool will not ... Dim iPos1 As Long ... Dim strReturn As String ...
    (microsoft.public.access.queries)