Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Programmatically Save a Database or Project as an MDE or ADE File


View products that this article applies to.

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

↑ Back to the top


Summary

This article describes how to programmatically create an MDE file from an existing database, or how to create an ADE file from an existing project.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. You can use Microsoft Visual Basic for Applications to create an MDE file from your existing Microsoft Access database or create an ADE file from your existing Microsoft Access Project. You can run the following sample function from any database or any project, other than the database or project that you want to convert to an MDE file or an ADE file. This function has one argument, MyPath, which is the full path to the database or the project from which to create the MDE file or the ADE file.

NOTE: You can use the SendKeys method to bypass the dialog box. Although this method permits you to programmatically save a database or a project as an MDE file or an ADE file, this method may cause an errant "ENTER" to be processed somewhere in one of your programs or in your open files. Use this method with caution.
  1. Create a new module, and then type the following function:
    Function GenerateMDEFile(MyPath As String)
    
       Dim NAcc As Access.Application
    
       Set NAcc = CreateObject("Access.Application")
    
       'The following lines simulate accepting the default
       'name, clicking Make MDE, and clicking Save
       SendKeys MyPath & "{Enter}{Enter}"
       SendKeys "{Enter}"
    
       NAcc.DoCmd.RunCommand acCmdMakeMDEFile
    
       Set NAcc = Nothing
    
    End Function
    					
    To run this function, follow these steps:

  2. Click Immediate Window on the View menu to open the Immediate window.
  3. Type ?GenerateMDEFile(<Path&DBName>), where <Path&DBName> is the full path and the database name or the project name from which you want to create an MDE file or an ADE file. Press ENTER.
NOTE: The resulting MDE file or ADE file has the same name as the original database or original project.

↑ Back to the top


References

For more information about MDE files, click Microsoft Access Help on the Help menu, type mde in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

For more information about ADE files, click Microsoft Access Help on the Help menu, type ade in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

↑ Back to the top


Keywords: KB202039, kbhowto

↑ Back to the top

Article Info
Article ID : 202039
Revision : 4
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 249