ACC2002: How to Programmatically Determine Whether the Current File Is an MDE or and ADE File (304251)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q304251
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SUMMARY

This article shows you how to programmatically determine if the currently open file is an MDE or ADE file.

MORE INFORMATION

Both Microsoft Access databases (MDBs) and projects (ADPs) have an MDE property that can be read to determine if the currently open file is an MDE (for an Access database) or and ADE (for an Access project). If the property does not exist, or is set to "F", the file is not an MDE or an ADE. If the property exists and is set to "T", the file is an MDE or an ADE.

The following steps use a function to look for the appropriate property and to determine its value, if present. The function returns True if the file is an MDE or an ADE or False if it is not:
  1. Start Access.
  2. On the Help menu, point to Sample Databases, and then click Northwind Sample Database.
  3. In the Database window, click Modules under Objects, and then click New to open a new module.
  4. Type or paste the following code in the new module, and then save the module:
    Function IsCompiledFile() As Boolean
        Dim strMDEADE As String
        On Error Resume Next
        If CurrentProject.ProjectType = acMDB Then
            strMDEADE = CurrentDb.Properties("MDE").Value
        Else  'type acADP
            strMDEADE = CurrentProject.Properties("MDE").Value
        End If
        IsCompiledFile = (Err.Number = 0 And strMDEADE = "T")
    End Function
    					
  5. In the Database window, click Forms under Objects, click New, and then click OK to open a new form in Design view.
  6. Add a command button to the new form.
  7. Set the OnClick property of the command button to the following event procedure:
    Dim bCheckValue As Boolean
    bCheckValue = IsCompiledFile()
    MsgBox bCheckValue
    					
  8. Close the Visual Basic environment to return to the form.
  9. Save the form, and then switch the form to Form view.
  10. Click the command button to run the underlying code.

    Note that you receive a message box with the word False because the currently open file is not an MDE.

Modification Type:MajorLast Reviewed:9/26/2003
Keywords:kbhowto KB304251