Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing recordsets

Status
Not open for further replies.

abenitez77

IS-IT--Management
Oct 18, 2007
147
US
I always close my recordset and set them to nothing. I do the same with database. Is it necessary to close the recordset if I put set rs = nothing after on the next line?
 
It is still best to do both.
But, I'd rather see you close them and not bother setting them to nothing than vice versa. In theory, every procedure cleans up after itself when it completes. This was less true in practice in earlier versions. Closing the recordset seems like to me it would be releasing the file lock whereas setting it to nothing has to do with the memory on your machine. If you have to reboot a client because of memory issues that is less of a concern for lost productivity while you wait for you file locks to get killed.
 
It cannot hurt, but 99% of the time neither are needed. Also setting it to nothing (assuming no other open pointers) should do the same as closing it
MSDN said:
An alternative to the Close method is to set the value of an object variable to Nothing
Long ago there were issues with DAO not working correctly and this was needed. This was not an issue with vb/vba but with DAO implementation. The only time I bother is if I am looping and opening multiple recordsets in code. Since the procedure does not exist before the next recordset is created then you would have to close explicitly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top