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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about database object Access

Status
Not open for further replies.

Crookshanks

Technical User
May 18, 2004
296
NL
Hello there,

I've got a small and simple question about the database object in Microsoft Access. I am using the DAO objectmodel. The structure of procedures with data changes is as follows:

set db = currrentDb
set rs = db.openrecordset(tablename): rs.index = "PrimaryKey"
....
....
rs.close: set rs = nothing: set db = nothing

Q: Is it wise to just set the db object at the beginnen of the runtime and close it afterwards. Or is the above mentioned structure recommended?

Regards,
 
Hi

It works either way. How about a compromise and put the set db = stattement in on on load event of each form and set db = nothing in each form unload event

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
IMO your original code is the preferred way. Always keep variables to as local a scope as possible.

The statement:

Set db = Nothing

does nothing to CurrentDB. You are simply setting db so it no longer points to CurrentDB.


 
Good point. You want to kill variables and objects no longer needed (even at the cost of extra code). Thanks for your contribution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top