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, 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
- 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:
Macro Name Action
--------------------------------
AutoExec RunCode
MsgBox
AutoExec Actions
-------------------------------
RunCode
Function Name: TestTransfer()
MsgBox
Message: Database Is Open!
- Quit Microsoft Access, and make a backup copy of Db2.mdb.
- 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
- When the database opens, click OK in the "Database Is Open!" message
box, and then quit Microsoft Access.
- 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.
- 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.
- 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