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!

I am fairly new to DAO recordsets,

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
US
I am fairly new to DAO recordsets, so I want to make sure I am doing things right. When I access a table in my database, I use the code:


Dim db as Database
Set db = CurrentDb()
Dim MyRecSet as DAO.Recordset
Set MyRecSet = db.OpenRecordset("SELECT * FROM MyTable", dbOpenDynaset, dbSeeChanges)

<< INSERT DATA MANIPULATION OR WHATEVER >>

MyRecSet.Close
Set MyRecSet = Nothing


Do I need to close my database (db)? If I execute this series often, is this going to be a problem with memory at all? Any tips? Thanks!
 
The only comment I'd make is that if you are using Access2002 you should be aware that MS are pushing people towards ADO instead of DAO. ADO works a bit differently and you need to choose which to use. If you want more info, let me know and I'll sugggest some useful reading.

youmike@mweb.co.za
 
As a more open question striker - What version of Access are you running ?


For an piece of code suitable for Access97 what you have put is FINE.

If this code appears in an event procedure or Sub on a Form or Report's Module page then you don't REALLY need
db.Close
Set db = Nothing
because all opbjects are set to nothing when they go 'out of scope'.
However, if you put the DIMs in the module header or in a General Module, or if the whole code is in a general module then you need to be very careful about where scope ends. - Or Close and 'Nothing everything once you've finished with it.


'ope-that-'elps.

G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top