Re: How to determine an Access DB's file format
- From: John Mishefske <jmishefskeNO@xxxxxxxxxxxxx>
- Date: Fri, 27 Apr 2007 19:33:58 -0500
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
.
- References:
- Re: How to determine an Access DB's file format
- From: John Mishefske
- Re: How to determine an Access DB's file format
- From: John Mishefske
- Re: How to determine an Access DB's file format
- Prev by Date: Re: How to determine an Access DB's file format
- Next by Date: ADO update and tables with more than 127 fileds
- Previous by thread: Re: How to determine an Access DB's file format
- Next by thread: Re: How to determine an Access DB's file format
- Index(es):
Relevant Pages
|