ACC1x: "Invalid Database Object" Error MessageID: Q94600
|
When you are trying to use a database object (database, QueryDef,
table, dynaset, snapshot) within Access Basic, you may receive the
following error message:
Invalid Database Object.
The problem occurs if you are within a transaction, you call
another function or procedure which dimensions the database, and
then leave the function or procedure which implicitly closes the
object that was opened within the transaction.
In this case Microsoft Access will try to close it and since it was
opened within a transaction, Microsoft Access will roll back all
levels of nested transactions.
If any other database objects were opened within the transaction,
rolling back has the effect of closing them. This means that any
references to an object opened within a transaction after another
object was forced to be implicitly closed will result in the "Invalid
database object" error message.
This problem will not occur if you always close database objects
before they go out of scope. The problem only occurs if you let
Microsoft Access implicitly close them.
This behavior no longer occurs in Microsoft Access version 2.0.
Function One ()
Dim MyDB As Database, MyTable As Table
Set MyDB = CurrentDB()
BeginTrans
Set MyTable = MyDB.OpenTable("Employees")
X = Two()
Debug.Print MyTable.RecordCount '"Invalid database object."
MyTable.Close
CommitTrans
MyDB.Close
End Function
Function Two ()
Dim MyDB2 As Database
Set MyDB2 = CurrentDB()
End Function
Function Two()
Dim MyDB2 as Database
Set MyDB2 = CurrentDB()
MyDB2.Close
End Sub
Keywords : kberrmsg kbprg MdlTran PgmObj
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: March 13, 1999