is MDE ?

  • Thread starter Thread starter AlexT
  • Start date Start date
A

AlexT

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

Regards

alex
 
A97 help:
Function IsItMDE(dbs as Database) As Boolean
Dim strMDE As String
On Error Resume Next
strMDE = dbs.Properties("MDE")
If Err = 0 AND strMDE = "T" Then
' This is an MDE database.
IsItMDE = True
Else
IsITMDE = False
End if
End Function

(david)
 
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.
 
AlexT said:
Thansk !

Just wondering.... is there a similar flag for ADP / ADE ?

As I recall, you can check the same property -- MDE -- for the same
value, "T". However, since CurrentDb is Nothing in an ADP/ADE, I
*think* you'd have to check the properties of CurrentProject instead.
I'm not sure of that, so I suggest you use Google Groups to search the
Access newsgroups for more information. Also, I think maybe you get a
different error number if the property doesn't exist. You can either
ignore all errors, rather than just that one, or else find out what that
error number is and check for it specifically.
 
Back
Top