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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing recordset operations question

Status
Not open for further replies.

gymbeef

Technical User
Sep 18, 2002
33
0
0
US
I've been going through my application doing some housekeeping to make it run faster and better, and I had a question regarding a recordset operation. I know enough to use them, but not enough to know if I'm doing it the best way, or sometimes even the right way! I want to make sure I close out the routine properly, clear variables, release memory, whatever. So, in a typical routine that goes:

Dim dDBS As Database
Dim rstDATA As Recordset
Set dDBS = CurrentDb
Set rstDATA = dDBS.OpenRecordset("Table name")
...
...

dDBS.Close
Set rstDATA = Nothing

Are the last lines in the right order? Do I need to set dDBS also to Nothing (before or after closing?)? Am I missing anything? Am I doing it right?

Thanks in advance.



 
I would reverse this..

set rstDATA = Nothing
dDBS.Close


the recordset is an object of the database, so technically when you close the database it should be released. Better habit to release it before closing the database. You can also set the dDBS = nothing at the very end.


Mike Pastore

Hats off to (Roy) Harper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top