By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,285 Members | 1,622 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,285 IT Pros & Developers. It's quick & easy.

Correct order for closing & setting to Nothing

P: n/a
MLH
MyRst.Close
Set MyRst = Nothing
MyDB.Close
Set MyDB = Nothing

Would the above be the correct order
in which to conduct the operations?
Oct 11 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a

MLH wrote:
MyRst.Close
Set MyRst = Nothing
MyDB.Close
Set MyDB = Nothing

Would the above be the correct order
in which to conduct the operations?
sounds right. close from the "inside" to the "outside".

Oct 11 '06 #2

P: n/a

MLH wrote:
MyRst.Close
Set MyRst = Nothing
MyDB.Close
Set MyDB = Nothing

Would the above be the correct order
in which to conduct the operations?
did you fall and hit your head or something or is this midlife crisis
or something? I always opened from the outside of the hierarchy in and
then close from the inside out.

Oct 12 '06 #3

P: n/a
pi********@hotmail.com wrote in
news:11**********************@k70g2000cwa.googlegr oups.com:
MLH wrote:
>MyRst.Close
Set MyRst = Nothing
MyDB.Close
Set MyDB = Nothing

Would the above be the correct order
in which to conduct the operations?

sounds right. close from the "inside" to the "outside".
It's a simpler explanation than that:

You can't close something that's been set to Nothing, so you have to
close first, and then set to Nothing.

This is because closing it releases the object variables data
structure and setting it to Nothing removes the reference to the
memory structure. They are two independent things, so you need to do
both.

Theoretically, setting to Nothing ought to release the memory (since
no references are left), but the whole point of all of this is that
things don't work the way they're supposed to, so you have to do it
manually.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Oct 12 '06 #4

P: n/a
MLH <CR**@NorthState.netwrote in
news:a3********************************@4ax.com:
MyRst.Close
Set MyRst = Nothing
MyDB.Close
Set MyDB = Nothing

Would the above be the correct order
in which to conduct the operations?
There's also the issue of "Should I close something I didn't explicitly
Open?"

This has been discussed at length in the past.

Here's one set.

http://tinyurl.com/yktxht

Cheers,
Alan Carpenter
Oct 12 '06 #5

P: n/a
MLH
I'm sorry. Were you replying to me or David?
Oct 13 '06 #6

P: n/a
MLH <CR**@NorthState.netwrote in
news:dh********************************@4ax.com:
I'm sorry. Were you replying to me or David?
My intention was to repy to you, but I see my aim was slightly off.
Sorry to both you and David. I know that David has the matter fully under
control.

Cheers,
Alan
Oct 13 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.