Multiple search values in one text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VBnewb13
    New Member
    • Jun 2010
    • 17

    #1

    Multiple search values in one text box

    I have a text box that I would like to type values in separated by a "," and be able to pull all matching values from the table it is searching.

    Here is what I have so far:

    Code:
    Forms!fsubDataSheet.RecordSource = "SELECT * FROM Table1 WHERE (Field1 Like '*" & [Forms]![frmDataSelect]![SearchALL] & "*'"
    the textbox called "SearchALL" is where I would like to type multiple values, whereas now I can only type one.

    Example: I would mostly be searching numbers.
    ####, ####, ####, ####
    thats 4 numbers separated by commas. I would like to search for each.

    I thought about creating a loop to see how many values I entered in the text box but I don't know how to put a loop within the sql statement I am using.

    Thanks
  • mseo
    New Member
    • Oct 2009
    • 183

    #2
    Originally posted by VBnewb13
    I have a text box that I would like to type values in separated by a "," and be able to pull all matching values from the table it is searching.

    Here is what I have so far:

    Code:
    Forms!fsubDataSheet.RecordSource = "SELECT * FROM Table1 WHERE (Field1 Like '*" & [Forms]![frmDataSelect]![SearchALL] & "*'"
    the textbox called "SearchALL" is where I would like to type multiple values, whereas now I can only type one.

    Example: I would mostly be searching numbers.
    ####, ####, ####, ####
    thats 4 numbers separated by commas. I would like to search for each.

    I thought about creating a loop to see how many values I entered in the text box but I don't know how to put a loop within the sql statement I am using.

    Thanks
    hi,
    I would suggest to use listbox control instead of textbox
    hope this helps

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Try :
      Code:
      With Forms!fsubDataSheet
          .Filter = "([Field1] In(" & [Forms]![frmDataSelect]![SearchALL] & ")"
          .FilterOn = True
      End With

      Comment

      Working...