If you open anything, close it.
If you did not open it, do not close it.
Regardless of whether you open it or not, set all object variables to
Nothing.
Example 1: Opening a recordset:
Dim rs As DAO.Recordset
Set rs = dbEngine(0)(0).OpenRecordset("MyTable")
'do something
rs.Close 'Correct: you opened it.
Set rs = Nothing 'Set any object to Nothing
Example 2: Refereing to an already open recordset.
Dim rs As DAO.Recordset
Set rs = Forms("MyForm").RecordsetClone
'do something
rs.Close '<=
WRONG! It was already open.
Set rs = Nothing 'Set any object to Nothing
--
Allen Browne -
Microsoft
MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html