G
Guest
After opening a recordset, when do you use the following:
rs.close
rs = nothing
What's the difference? Thanks!
rs.close
rs = nothing
What's the difference? Thanks!
Cheryl said:and I believe the correct syntax (pre-.NET) is "set rs=nothing"
rs.Close
rs = db.openRecordset("SELECT * FROM tblReservations WHERE location =
"Home")
[Code]
rs.Close
rs = db.OpenRecordset("SELECT * FROM tblGuests")
[Code]
rs.Close
Set rs = Nothing
The example above opens three different recordsets using the same
recordset object. In a way, its like calling your Office and asking to
speak to person #1, then #2, then #3 without ever hanging up. As opposed
to speaking person #1 then hanging up calling the exact same number to
speak with person #2.
David C. Holley said:rs.close Closes the recordset, but leaves the rs Object in existance.
Set rs = nothing (as it should be)
Does just that and cleans up the variable.
The difference is the OBJECT still exists so you could have a code like this
Set db = CurrentDb()
Set rs = db.openRecordset("SELECT * FROM tblReservations WHERE dteDate =
#10/31/2005#)
Code:rs.Close rs = db.openRecordset("SELECT * FROM tblReservations WHERE location = "Home") [Code] rs.Close rs = db.OpenRecordset("SELECT * FROM tblGuests") [Code] rs.Close Set rs = Nothing The example above opens three different recordsets using the same recordset object. In a way, its like calling your Office and asking to speak to person #1, then #2, then #3 without ever hanging up. As opposed to speaking person #1 then hanging up calling the exact same number to speak with person #2. [QUOTE] After opening a recordset, when do you use the following: rs.close rs = nothing What's the difference? Thanks![/QUOTE] [/QUOTE]
Set rs = nothing
Set parm = nothing
Set qry = nothing
Set db = nothing
While I have heard rumors that Access now cleans up object variables on
its own, I have not actually seen documentation to that effect *AND* it
was drilled into me that it is always be to EXPLICITY cleanup after
yourself. (Mom taught me that)
David H
[QUOTE]
Thanks to all three of you. It's funny though, to me, it would make more
since for them to be reversed based on the verbiage...
:
[QUOTE]
rs.close Closes the recordset, but leaves the rs Object in existance.
Set rs = nothing (as it should be)
Does just that and cleans up the variable.
The difference is the OBJECT still exists so you could have a code like this
Set db = CurrentDb()
Set rs = db.openRecordset("SELECT * FROM tblReservations WHERE dteDate =
#10/31/2005#)
[CODE]
rs.Close
rs = db.openRecordset("SELECT * FROM tblReservations WHERE location =
"Home")
[Code]
rs.Close
rs = db.OpenRecordset("SELECT * FROM tblGuests")
[Code]
rs.Close
Set rs = Nothing
The example above opens three different recordsets using the same
recordset object. In a way, its like calling your Office and asking to
speak to person #1, then #2, then #3 without ever hanging up. As opposed
to speaking person #1 then hanging up calling the exact same number to
speak with person #2.
[QUOTE]
After opening a recordset, when do you use the following:
rs.close
rs = nothing
What's the difference? Thanks![/QUOTE]
[/QUOTE][/QUOTE]
What you open, always close. What you create always destroy.
I hear a song ......
;-)
Set rs = nothing
Set parm = nothing
Set qry = nothing
Set db = nothing
While I have heard rumors that Access now cleans up object variables on
its own, I have not actually seen documentation to that effect *AND* it
was drilled into me that it is always be to EXPLICITY cleanup after
yourself.
How do you determine if the recordset still exists after closing it?