title: getting run time error 91 [object variable or with block variable not set]
body: <p>i am trying the code below to pull from access db, but getting error 91, please suggest how to remove the error.</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
      Dim con As ADODB.Connection
  
      Dim rs As ADODB.Recordset
  
      Dim strConn As String
  
      Set con = New ADODB.Connection
  
      con.Mode = adModeReadWrite
  
      If con.State = adStateClosed Then
  
        strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &amp; "C:\temp\db2.mdb;Persist    Security Info=False;"
  
        con.ConnectionString = strConn
  
        con.Open
  
      End If
  
      Dim startRow As Integer
  
      ***Set rs.ActiveConnection = con***
  
      rs.Open "select * from tbl_name"
      startRow = 3
      Do Until rs.EOF
         Cells(startRow, 4) = rs.Fields(0).Value
         rs.MoveNext
         startRow = startRow + 1
      Loop
  
      rs.Close
      Set rs = Nothing
      con.Close
      Set con = Nothing
  End Sub
  </code></pre>