How to know in an MS Access database if its an MDE

  • Thread starter Thread starter Johann Schwarz
  • Start date Start date
J

Johann Schwarz

Hi all !
I have some code in my Mdb, which opens design mode does some changes and
closes it again. The program in the end is compiled to an mde. In that case
this obviously doesn't work, so I want to prevent the user for using this in
the mde version. Is there any possibility to Check by code if the mdb is
still an mdb or if its a compiled version as an mde. Or is it possible to
allow the user to open design mode in a compiled mde.

Thx for comments

Johann Schwarz
 
Hi.

First, I would ask why this code is available for the users to run in the
first place. Not knowing anything about your database I can't say for sure,
but you may want to re-think your design.

Second, try this:
Right(CurrentDb.Name,3)

-Michael
 
Sorry, but that's a pretty unreliable test. The file can be named anything:
it doesn't have to be MDB or MDE.

You can look for the MDE property of the database object
(CurrentDb.Properties!MDE), which will be the letter "T" in an MDE, and
which will not exist in the non-MDE.

(Note that looking for a property that doesn't exist will generate an error,
so your code has to be able to handle that error)

In other words, you could have a function like this that will return True if
the current database is an MDE, and False otherwise:

Function IsMDE(DatabaseObject As DAO.Database) As Boolean
On Error Resume Next

IsMDE = (DatabaseObject.Properties!MDE = "T")

End Function

You'd call this as IsMDE(CurrentDb)
 
Back
Top