ACC2: TransferDatabase Fails in Code, Not in Immediate WindowID: Q117612
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
When you use the TransferDatabase action within a transaction in an Access
Basic function, you receive the error message:
Couldn't update, locked by another user on this system.
-or-
Couldn't update, currently locked by another session on this machine.
This error occurs only when you run a TransferDatabase action nested in a
transaction on a table that is already attached to Microsoft Access.
The error occurs because a transaction updates the MySysObjects table,
placing a write lock on the table. The write lock is not released while the
transaction is still active. The DoCmd TransferDatabase statement causes
Microsoft Access to start a new session and try to create a new table.
However, the Microsoft Jet database engine needs to update the MySysObjects
table because it is adding a record, but the MySysObjects table is still
locked.
Do not use nested TransferDatabase actions in transactions against attached
tables. Instead, use the following techniques:
Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0.
Function TestIt ()
Dim ws as Workspace
Dim db As Database, rs As Recordset
BeginTrans
set ws=dbengine.workspaces(0)
Set db = ws.databases(0)
Set rs = db.OpenRecordset("Order Details", DB_OPEN_DYNASET)
rs.FindFirst "[Order Id]=10010"
rs.Edit
rs![Order Id] = 10001
rs.Update
DoCmd TransferDatabase A_EXPORT, "Microsoft Access",_
"C:\ACCESS\SAMPAPPS\NWIND.MDB", A_TABLE, "Employees",_
"Employees2", False
CommitTrans
End Function
For more information about the TransferDatabase action, search for "TransferDatabase," and then "TransferDatabase Action" using the Microsoft Access Help menu.
Additional query words: programming attaching
Keywords : kberrmsg kbusage McrProb
Version : 2.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 6, 1999