Brett Barabash
BBarabash at TappeConstruction.com
Tue Nov 16 11:08:28 CST 2004
John, The Database object instantiates a Recordset to return the field value for you. Since the Recordset instance is not assigned to a variable, it is instantly out of scope and VBA's garbage collection will automatically destroy and cleanup its instance. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Colby, John Sent: Tuesday, November 16, 2004 8: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 -------------------------------------------------------------------------------------------------------------------- The information in this email may vileged. The information is only for the use of the intended recipient(s) named above. If you are not the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or the taking of any action in regard to the content of this email is strictly prohibited. If transmission is incorrect, unclear, or incomplete, please notify the sender immediately. The authorized recipient(s) of this information is/are prohibited from disclosing this information to any other party and is/are required to destroy the information after its stated need has been fulfilled. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Tappe Construction Co. This footer also confirms that this email message has been scanned for the presence of computer viruses.Scanning of this message and addition of this footer is performed by SurfControl E-mail Filter software in conjunction with virus detection software.