I have some code that counts the number of records an SQL statement returns.
It works fine, I am just wondering, is the recordset being left open and eating up resources?
Will it be closed when the VBA Sub ends? Or when the form is closed?
If so I could do it this way:
Or is there a better version of the first way?
Thanks.
It works fine, I am just wondering, is the recordset being left open and eating up resources?
Will it be closed when the VBA Sub ends? Or when the form is closed?
Code:
SQL = "SELECT COUNT(*) FROM QuotesQueryLimited WHERE [Quote Stage]='ECL - Saved';"
MsgBox CurrentDb.OpenRecordset(SQL, dbOpenForwardOnly, dbSeeChanges).Fields(0).Value
If so I could do it this way:
Code:
SQL = "SELECT COUNT(*) FROM QuotesQueryLimited WHERE [Quote Stage]='ECL - Saved';"
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset(SQL, dbOpenForwardOnly, dbSeeChanges)
MsgBox rst.Fields(0).Value
rst.Close
Set rst = Nothing
Or is there a better version of the first way?
Thanks.