Close Method (DAO)

Microsoft DAO 3.60

Close Method

           

Closes an open DAO object.

Syntax

object.Close

The object placeholder is an object variable that represents an open Connection, Database, Recordset, or Workspace object.

Remarks

Closing an open object removes it from the collection to which it's appended. Any attempt to close the default workspace is ignored.

If the Connection, Database, Recordset, or Workspace object named by object is already closed when you use Close, a run-time error occurs.

Caution If you exit a procedure that declares Connection, Database, or Recordset objects, those objects are closed, all pending transactions are rolled back, and any pending edits to your data are lost.

If you try to close a Connection or Database object while it has any open Recordset objects, the Recordset objects will be closed and any pending updates or edits will be canceled.  Similarly, if you try to close a Workspace object while it has any open Connection or Database objects, those Connection and Database objects will be closed, which will close their Recordset objects.

Using the Close method on either an original or cloned Recordset object doesn't affect the other Recordset object.

To remove objects from updatable collections other than the Connections, Databases, Recordsets, and Workspaces collections, use the Delete method on those collections. You can't add a new member to the Containers, Documents, and Errors collections.

An alternative to the Close method is to set the value of an object variable to Nothing (Set dbsTemp = Nothing).