You 'never' have to close an object. VBA 'always'
closes objects when they go out of scope.
"close what you open" is not the same as
"close if you use the key word 'open'
========
Access/VBA users 'never' have to close an object.
VBA 'always' closes objects when they go out of scope.
However, even with Access/VBA there is no documented
information on WHEN the VBA background task will
close an object. Also, you need to explicitly close
objects if you have reference loops (not relevant in
this example), and sometimes when you certain kinds
of implicit create/open bugs (where the object reference
gets lost).
It is different with ASP/VBscript. ASP/VBScript
objects don't go out of scope like they do when
running procedures in Access/VBA. ASP/VBScript
authors 'always' have to close objects. The supervisor
program 'never' closes objects for you.
It is also different from classic C. Classic C did
not have a management program that silently opened and
closed objects for you as a background process. In
Classic C you 'always' had to have an explicit close.
Regarding the explicit open: don't get the confused
by the mantra "close what you open". Two points:
(1) they didn't say "close if you use the key word 'open'"
and
(2) that's a classic C proverb: If you decide to
always use .close, do so because it is required in
ASP/VB script, or because it is your coding practice,
or because it deals with specific bugs, not because
it was a requirement in 1970.
(david)
"Darryl Kerkeslager" <ke*********@comcast.net> wrote in message
news:9Z******************************@comcast.com. ..
When I open an ADO Recordset, I close it. However, it seems that there
may be some difference in this manner of opening a Recordset:
Dim rL As ADODB.Recordset
Set rL = New ADODB.Recordset
src = "SELECT Count(*) FROM reviewer INNER JOIN pp_officer " & _
"ON reviewer.reviewer_id = pp_officer.ppo_rev_id " & _
"WHERE rev_login = 'EllisonL'"
Set rL = CurrentProject.Connection.Execute(src, , adCmdText)
c = rL.Fields(0)
rL.Close
In this type of Recordset, is the Close statement still necessary - there
is, after all, no explicit Open?
--
Darryl Kerkeslager