ACC95: TransferDatabase/CopyObject in Run-Time May Corrupt Object

ID: Q158923


The information in this article applies to:


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 and 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.


  5. 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 
  6. Save the module and close it.


  7. Create the following new macro called AutoExec:


  8. 
          Macro Name    Action
          --------------------------------
          AutoExec      RunCode
                        MsgBox
    
          AutoExec Actions
          -------------------------------
          RunCode
             Function Name: TestTransfer()
          MsgBox
             Message: Database Is Open! 
  9. Quit Microsoft Access, and make a backup copy of Db2.mdb.


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


  11. "C:\MSOffice\Access\MSAccess.exe" "C:\My Documents\Db2.mdb" /Runtime
  12. When the database opens, click OK in the "Database Is Open" message box, and then quit Microsoft Access.


  13. 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.


  14. 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.


  15. 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."

Additional query words:


Keywords          : kbprg kbdta AccCon IsmIea MdlOthr KbVBA 
Version           : WINDOWS:7.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: August 2, 1999