ACC95: TransferDatabase/CopyObject in Runtime May Corrupt Object

Last reviewed: August 29, 1997
Article ID: Q158923
The information in this article applies to:
  • Microsoft Access 7.0

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

If you use the /Runtime command-line option to open a database that uses TransferDatabase or CopyObject to import or export a Microsoft Access object, objects in the target database may become corrupted.

This applies to the TransferDatabase and CopyObject methods of the DoCmd object, as well as to the TransferDatabase and CopyObject macro actions.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Access version 7.0. This problem no longer occurs in Microsoft Access 97.

MORE INFORMATION

This problem only occurs when you are importing or exporting an object that contains a Visual Basic code module: Forms, Reports, or Modules. If you use TransferDatabase or CopyObject to import or export Tables, Queries or Macros the problem does not occur.

Steps to Reproduce Problem

  1. Start Microsoft Access and create a new database called Db1.mdb.

  2. Create a new, blank report, and save it as Report1.

  3. Create another new database called Db2.mdb.

  4. Create a module called Module1, and type the following procedure:

    NOTE: In the following procedure, replace "C:\My Documents\Db1.mdb" with the correct path to the database you created in step 1.

          Function TestTransfer()
    
             DoCmd.TransferDatabase acImport, "Microsoft Access", _
                "C:\My Documents\Db1.mdb", acReport, "Report1", "Report1"
          End Function
    
    

  5. Save the module and close it.

  6. Create the following new macro called AutoExec:

          Macro Name    Action
          --------------------------------
          AutoExec      RunCode
                        MsgBox
    
          AutoExec Actions
          -------------------------------
          RunCode
             Function Name: TestTransfer()
          MsgBox
             Message: Database Is Open!
    
    

  7. Quit Microsoft Access, and make a backup copy of Db2.mdb.

  8. Open the Db2.mdb database using the /runtime command-line switch. For example, create a shortcut or program icon with the following command line:

          "C:\MSOffice\Access\MSAccess.exe" "C:\My Documents\Db2.mdb" /Runtime
    

  9. When the database opens, click OK in the "Database Is Open!" message box, and then quit Microsoft Access.

  10. Start Microsoft Access and open Db2.mdb.

        NOTE: When you open the database, the AutoExec macro runs again.
        Because Report1 was already imported from Db1.mdb, it is imported this
        time as Report11.
    

  11. When you see the "Database Is Open!" message box, click OK, and then

        try to open Module1 in Design view. Note that you receive an empty
        warning box, and when you click OK, no code module is visible. The same
        thing happens if you open Report1 in Design view, and then click Code
        on the View menu.
    

  12. Open Report11 in Design view and click Code on the View menu. Because

        this report was created when the database was opened without the
        /Runtime switch, the code module opens without any problems.
    

REFERENCES

For more information about TransferDatabase, search the Help Index for "TransferDatabase."

For more information about CopyObject, search the Help Index for "CopyObject."

Keywords          : kbprg MdlOthr IsmIea
Version           : 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.