title: MS Access: How to bypass/suppress an error?
body: <p>I'm executing a query like this</p>
  
  <pre><code>select field from table;
  </code></pre>
  
  <p>In that query, there is a loop running on many tables. So, if the field is not present in a table I get a </p>
  
  <blockquote>
    <p>Runtime Error 3061</p>
  </blockquote>
  
  <p>How can I by pass this error such as that on this error flow should go to another point?</p>
  
  <p>This is the code I have recently after going through this forum.</p>
  
  <pre><code>Option Explicit
  
  Private Sub UpdateNulls()
   Dim rs2 As DAO.Recordset
    Dim tdf As DAO.TableDef
    Dim db As Database
    Dim varii As Variant, strField As String
    Dim strsql As String, strsql2 As String, strsql3 As String
    Dim astrFields As Variant
    Dim intIx As Integer
    Dim field As Variant
    Dim astrvalidcodes As Variant
    Dim found As Boolean
    Dim v As Variant
  
  
    Open "C:\Documents and Settings\Desktop\testfile.txt" For Input As #1
    varii = ""
    Do While Not EOF(1)
      Line Input #1, strField
      varii = varii &amp; "," &amp; strField
    Loop
    Close #1
    astrFields = Split(varii, ",")  'Element 0 empty
  
  
  
  
          For intIx = 1 To UBound(astrFields)
  
  
          'Function ListFieldDescriptions()
                              Dim cn As New ADODB.Connection, cn2 As New ADODB.Connection
                              Dim rs As ADODB.Recordset, rs3 As ADODB.Recordset
                              Dim connString As String
                              Dim SelectFieldName
  
                              Set cn = CurrentProject.Connection
  
                              SelectFieldName = astrFields(intIx)
  
                              Set rs = cn.OpenSchema(adSchemaColumns, Array(Empty, Empty, Empty, SelectFieldName))
  
                             'Show the tables that have been selected '
                              While Not rs.EOF
  
                             'Exclude MS system tables '
                              If Left(rs!Table_Name, 4) &lt;&gt; "MSys" Then
                              strsql = "Select t.* From [" &amp; rs!Table_Name &amp; "] t Inner Join 01UMWELT On t.fall = [01UMWELT].fall Where [01UMWELT].Status = 4"
                              End If
  
                              Set rs3 = CurrentDb.OpenRecordset(strsql)
  
              'End Function
  
              strsql2 = "SELECT label.validcode FROM variablen s INNER JOIN label ON s.id=label.variablenid WHERE varname='" &amp; astrFields(intIx) &amp; "'"
  
              Set db = OpenDatabase("C:\Documents and Settings\Desktop\Codebook.mdb")
              Set rs2 = db.OpenRecordset(strsql2)
  
                  With rs2
                  .MoveLast
                  .MoveFirst
                   astrvalidcodes = rs2.GetRows(.RecordCount)
                  .Close '
                  End With
  
  
                      With rs3
                      .MoveFirst
                      While Not rs3.EOF
                          found = False
                          For Each v In astrvalidcodes
                          If v = .Fields(0) Then
                          found = True
                          Debug.Print .Fields(0)
                          Debug.Print .Fields(1)
  
  
                Exit For
                      End If
                      Next
                  If Not found Then
                  msgbox "xxxxxxxxxxxxxxxx"
  
                  End If
                  End If
                  .MoveNext
  
  
                  Wend
                  End With
  
             On Error GoTo 0        'End of special handling
  
      Wend
  
  
  
  Next intIx
  
  
    End Sub
  </code></pre>
  
  <p>I'm getting a</p>
  
  <blockquote>
    <p>Type Mismatch Runtime Error </p>
  </blockquote>
  
  <p>in <code>Set rs3 = CurrentDb.OpenRecordset(strsql)</code></p>
  
  <p>I guess I'm mixing up <code>ado</code> and <code>dao</code> but I'm not certainly sure where it is.</p>