"Trevor Best" <no****@besty.o rg.uk> wrote in message
news:42******** **************@ news.zen.co.uk. ..
Tom wrote: "If Not RstSurveySectio n Is Nothing Then"
worked fine!
You still need to error trap, consider this
Set RstSurveySectio n = db.openrecordse t....
...some code
RstSurveySectio n.close
... some code
if not RstSurveySectio n is nothing then
RstSurveySectio n.close ' <<<< Error will occur here
set RstSurveySectio n=nothing
end if
RstSurveySectio n can be closed or become invalid even if you don't
explicitly close it yourself, VBA isn't perfect or invunerable to cosmic
rays :-)
--
[OO=00=OO]
Indeed, so you might have it as part of your 'exit block' like:
Exit_MySub:
On Error Resume Next
If Not RstSurveySectio n Is Nothing Then
RstSurveySectio n.Close
Set RstSurveySectio n = Nothing
End If
Exit Sub
However, if you have the above error handling, it is doubtful whether it is
even worth checking if the object is nothing or not. In other words, you
might as well have:
Exit_MySub:
On Error Resume Next
RstSurveySectio n.Close
Set RstSurveySectio n = Nothing
Exit Sub
Having said that, I tend to write code as in the first example - it just
means that my coding always looks recognisable.