Reuse of DAO Recordsets

  • Thread starter Thread starter Alex Dybenko
  • Start date Start date
Just a question that I have been wondering about. I have recently started
using more and more recordsets to handle data in applications I have been
writting. Now I am mostly self taught so I don't have a perfect handle on
everything access can do and can't do but I try to make use of everything I
can.

The question is, when you open a recordset, use it to do what you need, then
close it using the .close command, do you need to set it to nothing before
you reuse the variable? Is this maybe good practice but not necessarily
required? I know that it should be set to nothing at the end of the
procedure and in any error catcher.

Example (air code please excuse typos and capitalization)

dim db as database
dim rst as recordset

set db = Currentdb()
set rst = db.openrecordset("myquery")

rst.movelast
rst.movefirst
rst.close

set rst = nothing 'Is this line necessary?

set rst = dbopenrecordset("mysecondquery")
..... and so on

Thanks in advance for any replies.

Kat
 
Since rst is dimmed as a recordset, after you close it, you can reuse it with
another Open. When you are completely done with it, although not required,
it is a good practice to set it to Nothing.
 
Back
Top