set DAO.QueryDef to nothing

I

iccsi

I have following code

Dim qdfCurr As DAO.QueryDef
Dim strMYSQL as string

strMYSQL = "SELECT * FROM MyTable"

Set qdfCurr = CurrentDb().QueryDefs("MyQuery")

qdfCurr.SQL = strMySQL

I just wonder do I need set DAO.QueryDef to nothing like
DAO.Recoerdset?

Your help is great appreciated,
 
D

Douglas J. Steele

Technically yes, any object you instantiate should be set back to Nothing
when you're done. In practice, though, I don't think it's really all that
critical anymore.
 
I

inungh

Technically yes, any object you instantiate should be set back to Nothing
when you're done. In practice, though, I don't think it's really all that
critical anymore.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)












- Show quoted text -

Thanks millions,
 
D

David W. Fenton

any object you instantiate should be set back to Nothing
when you're done.

Also, if you want to be really picky (and follow Michael Kaplan's
advice), implicitly instantiated objects should also be cleaned up:

For Each qdf In CurrentDB.QueryDefs
...
Next qdf
Set qdf = Nothing
In practice, though, I don't think it's really all that
critical anymore.

I have the habit and know that I'm avoiding the very remote
possibility of the kind of bug that could be incredibly difficult to
troubleshoot should it ever cause a problem.
 
D

Douglas J. Steele

David W. Fenton said:
I have the habit and know that I'm avoiding the very remote
possibility of the kind of bug that could be incredibly difficult to
troubleshoot should it ever cause a problem.

Oh, I have the habit too. I'm starting to have problems justifying it to
myself though. <g>
 
D

David W. Fenton

Oh, I have the habit too. I'm starting to have problems justifying
it to myself though. <g>

I think it serves as much purpose as good comments, as you have to
think about the process of cleaning up the objects you instantiate,
even if you could probably get away with not bothering.
 
D

Douglas J. Steele

David W. Fenton said:
I think it serves as much purpose as good comments, as you have to
think about the process of cleaning up the objects you instantiate,
even if you could probably get away with not bothering.

Valid point. Thanks.
 

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