shadow9449
Registered User.
- Local time
- Today, 17:25
- Joined
- Mar 5, 2004
- Messages
- 1,037
I have some forms that have unbound areas that draw from different recordsets (tables, queries and so on). In order to populate these areas, I call the respective recordsets, draw the data and then close the recordset.
Here's some pseudo-code to show how I do it:
It's clear from everything that I've read that you should close the recordset and database that you opened and then set them to nothing as I have in the last section of the code. BUT note that in the course of execution, rs will be set to many different recordsets before I close it at the end.
My question is if it would be better practice to close rs EVERY time I've drawn data before I set it to another recordset? I don't know enough about Access' memory management to know how this is best done.
As an aside, I used to rely on Dlookup for the same task until I've read about how much more efficient using DAO is and I would guess that many people still do this.
Thank you
SHADOW
Here's some pseudo-code to show how I do it:
Code:
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset({My first recordset to open})
If rs.RecordCount > 0 Then
{show the data on the section of the form}
End if
Set rs = db.OpenRecordset({My second recordset to open})
If rs.RecordCount > 0 Then
{show the data on the section of the form}
End if
and so on...
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
It's clear from everything that I've read that you should close the recordset and database that you opened and then set them to nothing as I have in the last section of the code. BUT note that in the course of execution, rs will be set to many different recordsets before I close it at the end.
My question is if it would be better practice to close rs EVERY time I've drawn data before I set it to another recordset? I don't know enough about Access' memory management to know how this is best done.
As an aside, I used to rely on Dlookup for the same task until I've read about how much more efficient using DAO is and I would guess that many people still do this.
Thank you
SHADOW