Close Method

The Close method on a Connection or Recordset object closes an open object and any dependent objects.

recordSet.Close AffectedRecords
 

Parameters

None.

Remarks

The Close method is used to close either a Connection object or a Recordset object to free any associated system resources. Closing an object does not remove it from memory; you may change its property settings and open it again later. To completely eliminate an object from memory, set the object variable to Nothing.

Using the Close method to close a Connection object also closes any active Recordset objects associated with the connection. A Command object associated with the Connection object you are closing will persist, but it will no longer be associated with a Connection object, that is, its ActiveConnection property will be set to Nothing.

You can later call the Open method to reestablish the connection to the same or another data source. While the Connection object is closed, calling any methods that require an open connection to the data source generates an error. Closing a Connection object while there are open Recordset objects on the connection rolls back any pending changes in all of the Recordset objects.

Using the Close method to close a Recordset object releases the associated data and any exclusive access you may have had to the data through this particular Recordset object. You can later call the Open method to reopen the recordset with the same or modified attributes. While the Recordset object is closed, calling any methods that require a live cursor generates an error.

If an edit is in progress while in immediate update mode, calling the Close method generates an error. The Update or CancelUpdate methods should be called first. If you close the Recordset object during batch updating, all changes since the last UpdateBatch call are lost.