Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End of Module Procedures?

Status
Not open for further replies.

jgarry

Programmer
Nov 23, 2004
67
US
Hi, thanks in advance. My question has to do with Recordsets and Database.

Using DAO on the top of modules I set the record sets up with

Dim rs as recordset
Dim db as database
Dim Tdf as Tabledef

No problems.

Now as I understand it I should at the end of my modules or when I am finished using them I should set them to nothing

Set rs = nothing
Set db = nothing
Set tdf = nothing

My questions are:
1. Is there anything else that should be set to nothing? Such as all my dim statements?
dim strSql as string
set that to:
set strSql = Nothing

2. Should I close the rs and db prior to setting to nothing or does setting them to nothing do that for you?

3. Is there anything else along these lines I should know or do for good coding practice?

Thanks
 
You only set object references to nothing, not other variables.

The only thing you may with to do, and I'm not sure it will help, is to redim any BIG array you have loaded on any form as soon as you don't need them.


I would close the objects before set to nothing.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
1. All the objects (ie the things instantiated with a Set instruction)
2. rs.Close: Set rs = Nothing: db.Close: Set db = Nothing
3. use Option Explicit, indent your code properly, comment it, ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top