[AccessD] What happens to the recordset?

Colby, John JColby at dispec.com
Tue Nov 16 08:59:14 CST 2004


I learned a long time ago that you could retrieve a value from a single
record recordset using syntax like:

    strInvAlt = db.OpenRecordset(strSQL)!TopExpense

where you don't dim a recordset, you just opened the recordset using
db.openrecordset() and then referenced a field of the recordset with the
!SomeField syntax.

My question is, the recordset itself is never assigned to a dimmed recordset
object.  Furthermore there is no db.CloseRecordset() syntax.  Does the
recordset just stay open until the database object itself is closed or is
used to open a different recordset?

I have a situation where I would dim a database object in the form header
and set that database object in OnOpen (to save the time it takes to Set
DB), then use this syntax to retrieve a value in OnCurrent.  I don't want
the recordset hanging out there though.  In thinking this through it seems
that if the db is not dimmed / set each time in the OnCurrent then I should
NOT use this syntax, but rather dim / set a recordset object as well in the
form header / OnOpen and then set the recordset object in the OnCurrent,
grab the field value and explicitly close the recordset (but NOT set the
recordset object = nothing)

Did that make any sense?  Thoughts on the subject?

John W. Colby
The DIS Database Guy




More information about the AccessD mailing list