2 'For Dummies' questions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Q1: I was always taught to set an object variable back to Nothing after I
finished using it, and all of the examples shown in Help do just that. Is it
really necessary to include all of those "Set x = Nothing" statements in the
code, particularly when the same object variable is simply assigned a new
value again and again? Does not doing so eat up memory, or cause other
problems?

Q2: When using the Repaint method, is it necessary to follow it with a
"DoEvents" to get immediate results?

Thanks,
Bruce
 
BruceS said:
Q1: I was always taught to set an object variable back to Nothing after I
finished using it, and all of the examples shown in Help do just that. Is it
really necessary to include all of those "Set x = Nothing" statements in the
code, particularly when the same object variable is simply assigned a new
value again and again? Does not doing so eat up memory, or cause other
problems?

If you're still using the object variable, then NO you do not have to
Set X = Nothing before SETting it again, until you're finished with it.
So code like this should be find...

Set db = CurrentDB
Set rs = db.OpenRecordset([recordset])
Code:
rs.close
Set rs = db.OpenRecordset ([different recordset])
[code]
rs.close
Set rs = Nothing

[QUOTE]
Q2:  When using the Repaint method, is it necessary to follow it with a
"DoEvents" to get immediate results?[/QUOTE]
Can't answer that definetivley as I've never needed to use DoEvents, but
when I have used .Repaint its worked like a charm.
 
Thanks, David!
Bruce

David C. Holley said:
Q1: I was always taught to set an object variable back to Nothing after I
finished using it, and all of the examples shown in Help do just that. Is it
really necessary to include all of those "Set x = Nothing" statements in the
code, particularly when the same object variable is simply assigned a new
value again and again? Does not doing so eat up memory, or cause other
problems?

If you're still using the object variable, then NO you do not have to
Set X = Nothing before SETting it again, until you're finished with it.
So code like this should be find...

Set db = CurrentDB
Set rs = db.OpenRecordset([recordset])
Code:
rs.close
Set rs = db.OpenRecordset ([different recordset])
[code]
rs.close
Set rs = Nothing

[QUOTE]
Q2:  When using the Repaint method, is it necessary to follow it with a
"DoEvents" to get immediate results?[/QUOTE]
Can't answer that definetivley as I've never needed to use DoEvents, but
when I have used .Repaint its worked like a charm.
[QUOTE]
Thanks,
Bruce[/QUOTE]
[/QUOTE]
 
Back
Top