title: Check if ADODB connection is open
body: <p>I use the following from within some excel procedures to establish a connection to our database.</p>
  
  <pre><code>Private Const strConn As String = _
      "PROVIDER=SQLOLEDB.1 ..."     
  
  Sub OpenConnection()
  
  Set cn = CreateObject("ADODB.Connection")
  cn.Open strConn
  cn.CommandTimeout = 0
  Set rs = CreateObject("ADODB.Recordset")
  Set rs.ActiveConnection = cn
  
  End Sub 
  </code></pre>
  
  <p>In subsequent code I open the connection using various SQL strings.<br>
  I'd like to test if <code>rs</code> is open so I know that it needs to be closed but the following does not work. How can I change the condition in the following to work?</p>
  
  <pre><code>If (rs.Open = True) Then
      rs.Close
  End If
  </code></pre>
  
  <p>The following works but I'd rather not use error trapping in this way:</p>
  
  <pre><code>On Error Resume Next
      rs.Close
  </code></pre>