Microsoft KB Archive/158923

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

Article ID: 158923

Article Last Modified on 9/13/2006

-

APPLIES TO


 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q158923



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



SYMPTOMS
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
 Start Microsoft Access and create a new database called Db1.mdb. Create a new, blank report, and save it as Report1. Create another new database called Db2.mdb.  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  Save the module and close it.  Create the following new macro called AutoExec: <pre class="fixed_text">     Macro Name    Action AutoExec     RunCode MsgBox

AutoExec Actions ---     RunCode Function Name: TestTransfer MsgBox Message: Database Is Open! </li> Quit Microsoft Access, and make a backup copy of Db2.mdb.</li> 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

</li> When the database opens, click OK in the "Database Is Open" message box, and then quit Microsoft Access.</li> 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.</li> 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.</li> 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.</li></ol>

<div class="references_section">