Reset a recordset?

  • Thread starter Thread starter Laurel
  • Start date Start date
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
 
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.
 
Back
Top