Reset a recordset?

L

Laurel

I have this code inside a loop. Should I be doing something to clear the
recordset before I repeat the "Set" statement?

ls_sql = "Select * from tblScores where student_id =" & !Student_id _
& " AND Score_Date = #" & is_ScoreDate & "#"
Set lrst_Scores = CurrentDb.OpenRecordset(ls_sql)

TIA
LAS
 
D

Dirk Goldgar

Laurel said:
I have this code inside a loop. Should I be doing something to clear the
recordset before I repeat the "Set" statement?

ls_sql = "Select * from tblScores where student_id =" & !Student_id _
& " AND Score_Date = #" & is_ScoreDate & "#"
Set lrst_Scores = CurrentDb.OpenRecordset(ls_sql)

TIA
LAS


You should certainly close the recordset at the bottom of the loop, before
looping around and reopening it:

lrst_Scores.Close

You shouldn't have to explicitly set it to Nothing afterward (Set
lrst_Scores = Nothing), but I can't guarantee that it makes no difference
whether you do or not. Sometimes VBA doesn't do all the cleanup that it
should. Someone else may be able to give you the guarantee that I cannot,
though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top