Microsoft KB Archive/304251

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

Article ID: 304251

Article Last Modified on 9/26/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



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 &quot;F&quot;, the file is not an MDE or an ADE. If the property exists and is set to &quot;T&quot;, 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:  Start Access. On the Help menu, point to Sample Databases, and then click Northwind Sample Database. In the Database window, click Modules under Objects, and then click New to open a new module.  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(&quot;MDE&quot;).Value Else 'type acADP strMDEADE = CurrentProject.Properties(&quot;MDE&quot;).Value End If   IsCompiledFile = (Err.Number = 0 And strMDEADE = &quot;T&quot;) End Function  In the Database window, click Forms under Objects, click New, and then click OK to open a new form in Design view. Add a command button to the new form.</li>  Set the OnClick property of the command button to the following event procedure: Dim bCheckValue As Boolean bCheckValue = IsCompiledFile MsgBox bCheckValue </li> Close the Visual Basic environment to return to the form.</li> Save the form, and then switch the form to Form view.</li> 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.</li></ol>

Additional query words: inf mde ade

Keywords: kbhowto KB304251

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.