AlexT said:
Folks
What is the best way to find out if the current project is an MDE or
an MDB ?
I am currently testing the current file name for the extension but I
guess it's not 100% reliable, as the user might rename it...
I don't know if this is the best way, but there's an MDE property of the
Database object that Access creates and sets to the value "T" for an MDE
database. The property won't normally exist in a non-MDE database, so
you have to be careful in testing it. I haven't actually done this
myself, but I believe something like this ought to work:
'----- start of code (warning: "air code") -----
Function IsMDE() As Boolean
On Error GoTo Err_Handler
If CurrentDb.Properties("MDB") = "T" Then
IsMDE = True
End If
Exit_Point:
Exit Function
Err_Handler:
' Note: error 3270 is "Property not found."
If Err.Number <> 3270 Then
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
End If
Resume Exit_Point
End Function
'----- end of code (warning: "air code") -----
Note that it is possible to manually create this property in an MDB
file, so this method could be spoofed. There may be a better way.