setting variables to nothing

  • Thread starter Nick 'The Database Guy'
  • Start date
N

Nick 'The Database Guy'

People,

I have a piece of code (please see below) and after I assign the
value, which I look up in a recordset, to a variable I close the
recordset and set both the object variables to equal nothing.

Dim intAutth As Integer
sql = "SELECT Authority " & _
"FROM tblUsers " & _
"WHERE Login =" & Environ("UserName")
Set db = CurrentDb
Set rs = db.OpenRecordset(sql, dbOpenDynaset, dbSeeChanges)
intauth = rs!Authority
rs.Close
Set rs = Nothing
Set db = Nothing

My question is this: Is it best practise to set both variables to
equal nothing or would setting the 'db' to nothing do exactly the same
job?

Thanks in advance.

Nick
 
B

Baz

There's a lot of nonsense talked in this area. There was a specific problem
in Access 97 with objects not being explicity destroyed, but I've never
experienced any problem since then and I rarely bother. My applications are
as stable as anyone's.
 
A

Allen Browne

In a perfect world, Access would clean up after itself without your needing
to do it.

We don't live in a perfect world. There have been cases where Access dosn't
clean up. Like you Mom taught you: if you open it, close it.
 

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