Why using .Close AND =Nothing?

J

JB

In various examples I have seen people using both .Close AND =Nothing

This is from the help in Access 2002:
"An alternative to the Close method is to set the value of an object
variable to Nothing (Set dbsTemp = Nothing)."

Should I use one of them or are both necesarry?
I just want to kill my object.
 
D

Dirk Goldgar

JB said:
In various examples I have seen people using both .Close AND =Nothing

This is from the help in Access 2002:
"An alternative to the Close method is to set the value of an object
variable to Nothing (Set dbsTemp = Nothing)."

Should I use one of them or are both necesarry?
I just want to kill my object.

Many of us use both because, after being burned in earlier releases, we
don't completely trust the object management and garbage collection
routines. So we explicitly close objects we've opened to make sure the
object takes care of the necessary processing, and we explicitly destroy
the reference by setting the object variable = Nothing, to make sure
that Access/VB doesn't accidentally maintain a reference to the closed
object, keeping it from being destroyed.

We shouldn't have to do this, if all the support routines are doing
their jobs. Maybe they are, these days. But time was when they
weren't.

Note: you do *not* want to close an object you didn't open, though you
should destroy the reference you got to it when you're through using it.
 
H

help

".close" can close the object
"set xxx=nothing" can clearn the variable from Memory
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top