[AccessD] What happens to the recordset?

Jim Lawrence (AccessD) accessd at shaw.ca
Tue Nov 16 09:55:54 CST 2004


Hi John:

There is a default recordset created when a form is opened and can be used
in all sorts of ways. When a bound form is opened the recordset is
pre-filled. You can access and use it like:

Dim rs as Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ContractNumber] = '" & Me![cmbFindContractNumber] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

When the form is closed both of the recordsets are automatically closed as a
clone can not exist without it's 'original'.

Your code is just another way of accessing it.

HTH
Jim

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Colby, John
Sent: Tuesday, November 16, 2004 6:59 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] What happens to the recordset?


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

--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list