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

A97: When to set var to Nothing?

P: n/a
MLH
Dim MyDB As Database, rstITSLttrs As Recordset, rstOtherTable As
Recordset
Set MyDB = CurrentDb()
Set rstITSLttrs = MyDB.OpenRecordset("qryITSLetterList",
dbOpenDynaset)
rstITSLttrs.MoveFirst
Do Until rstITSLttrs.EOF
....

In the above snippet, which of the dim'd vars should be set to Nothing
at the end of their usefulness? For example, I'm unsure if setting
MyDB to Nothing at the end really accomplishes anything at all.
May 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
MLH wrote:
Dim MyDB As Database, rstITSLttrs As Recordset, rstOtherTable As
Recordset
Set MyDB = CurrentDb()
Set rstITSLttrs = MyDB.OpenRecordset("qryITSLetterList",
dbOpenDynaset)
rstITSLttrs.MoveFirst
Do Until rstITSLttrs.EOF
...

In the above snippet, which of the dim'd vars should be set to Nothing
at the end of their usefulness? For example, I'm unsure if setting
MyDB to Nothing at the end really accomplishes anything at all.


You shouldn't "have" to set any of them to nothing. Because that doesn't
always work as advertised the usual advice is to set them all to nothing in
the reverse order that they are dimmed.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
May 10 '06 #2

P: n/a
"Rick Brandt" <ri*********@hotmail.com> wrote in
news:fq*******************@newssvr14.news.prodigy. com:
MLH wrote:
Dim MyDB As Database, rstITSLttrs As Recordset, rstOtherTable As
Recordset
Set MyDB = CurrentDb()
Set rstITSLttrs = MyDB.OpenRecordset("qryITSLetterList",
dbOpenDynaset)
rstITSLttrs.MoveFirst
Do Until rstITSLttrs.EOF
...

In the above snippet, which of the dim'd vars should be set to
Nothing at the end of their usefulness? For example, I'm unsure
if setting MyDB to Nothing at the end really accomplishes
anything at all.


You shouldn't "have" to set any of them to nothing. Because that
doesn't always work as advertised the usual advice is to set them
all to nothing in the reverse order that they are dimmed.


And all recordset variables should be closed before setting them to
Nothing, as well as any database variable that is pointing to
anything other than the MDB currently open in the Access UI.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
May 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.