title: Ms Access Form - How to completely filter text using search button
body: <pre><code>`Option Compare Database
  
  Option Explicit
  Dim argcount As Integer
  Dim mysql As String, msg As String, mysource As String, mycriteria As String,                   mysource1 As String, mysql1 As String
  
   Private Sub AddtoWhere(FieldValue As Variant, FieldName As String, mycriteria As String, argcount As Integer)
  
  '  Create criteria for WHERE clause.
  If FieldValue &lt;&gt; "" Then
      '  Add "and" if other criterion exists.
      If argcount &gt; 0 Then
          mycriteria = mycriteria &amp; " and "
      End If
  
      '  Append criterion to existing criteria.
      '  Enclose FieldValue and asterisk in quotation marks.
      mycriteria = (mycriteria &amp; FieldName &amp; " Like " &amp; Chr(34) &amp; FieldValue &amp; Chr(42) &amp; Chr(34))
  
      '  Increase argument count.
      argcount = argcount + 1
  End If
  
  End Sub
  
  Private Sub Search_Click()
  
  Dim Search As String
  
  here:
  argcount = 0
  
  '  Initialize SELECT statement.
  mysql = "SELECT * FROM tbltab WHERE "
  mycriteria = ""
  mysql1 = "SELECT * FROM tblTemp WHERE "
       mycriteria = ""
  '  Use values entered in text boxes in form header to create criteria for         WHERE clause.
  
  AddtoWhere cboProduct, "ABC1", mycriteria, argcount
  AddtoWhere cboSource, "ABC2", mycriteria, argcount
  AddtoWhere cboPType, "ABC3", mycriteria, argcount
  
  'If no criterion specifed, stop the search.
  'you'll be glad you did if there are thousands of Persons maybe.
  If mycriteria = "" Then
  mycriteria = True
  
  End If
  
  
  '  Create SELECT statement.
  
  mysource = mysql &amp; mycriteria
  
  mysource1 = mysql1 &amp; mycriteria
  
  Dim strval As String
  
     'set the recordsource of the subform to the resultset
  
  Me!sfrmCap.Form.RecordSource = mysource
  
  Me!sfrmCapTemp.Form.RecordSource = mysource1
  
  Exit_cmdsearch_Click:
  Exit Sub
  Err_cmdsearch_Click:
  
  DoCmd.Hourglass False
  
  DoCmd.Echo True
  
  MsgBox Err.Description &amp; " Person Search Command Cancelled", vbInformation,     "Person Search Command Cancelled"
  
  Resume Exit_cmdsearch_Click
  
  End Sub
  </code></pre>
  
  <p>`I have a form in which there are 2 subform. I have a search button which when click search record using combo box values but in one combo box it display just related record not the complete search.</p>
  
  <p>Can anyone help me in this.</p>
  
  <p>Thank you.</p>