title: Why is my SQL statement behaving this way when using AND or OR - Visual Basic
body: <p>I have a form with two radio buttons(SSOP or SCOP), six checkboxes and 1 combobox. Based on the radio button choice, the combobox gets populated then filtered with the checkboxes (multiple checkboxes can be chosen)</p>
  
  <p>I have written the code below and when i choose only checkbox it works perfectly, displaying only the SSOP of that checkbox. But when i choose more than one checkbox it shows me both the SSOP and the SCOP. as if the LIKE statement is bypassed. Why is that?</p>
  
  <p>Thanks</p>
  
  <pre><code>    Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles 
      btnSearch.Click
  
   SQLa = "SELECT * FROM ARES_Procedure_List WHERE ARES_ID LIKE '%SSOP%' "
          Dim strChk As String = ""
          Dim chk As CheckBox
          Dim strSubsystem As String = ""
          Dim listSubsystem As List(Of [String]) = New List(Of String)
          For Each ctl As Control In Me.Controls
              If TypeOf ctl Is CheckBox Then
                  chk = DirectCast(ctl, CheckBox)
                  If chk.Checked = True Then
                      listSubsystem.Add("Subsystem = '" &amp; 
           Microsoft.VisualBasic.Mid(chk.Text, 1) &amp; "'")
  
                  End If
              End If
  
          Next
          strSubsystem = [String].Join(" OR ", listSubsystem.ToArray())
          Label1.Text = strSubsystem
          SQLa = SQLa &amp; "AND " &amp; strSubsystem &amp; ""
          MsgBox(SQLa)
          CallAccess()
          cboSelect.Items.Clear()
          Do Until RSa.EOF()
          cboSelect.Items.Add(RSa.Fields("ARES_ID").Value)
          RSa.MoveNext()
          Loop
          CloseAccess()
      End Sub
  </code></pre>