Handy IsOpen(ADODBs) Function

J

Jim Shores

Hi.
Is there some way I can test and see if those recordsets, connections, tables and whatnot are open? Probably not? What about error-trapping them closed when my dumb code makes stuff spin out of control?
All this is way more, "robust," than it used to be 10 yrs ago
 
D

Dan Artuso

Hi,
If you're using ADO, both the Connection and Recordset objects have a State peoperty
that will tell you if they are open or not.
Ths allows you to write code like this:

If cnn.State = adStateOpen Then
cnn.Close
End If

If Not cnn Is Nothing Then
Set cnn = Nothing
End If

--
HTH
Dan Artuso, Access MVP


Jim Shores said:
Hi.
Is there some way I can test and see if those recordsets, connections, tables and whatnot are open? Probably not? What about
error-trapping them closed when my dumb code makes stuff spin out of control?
 
Top