Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2004
    Posts
    19

    Angry Unanswered: Searching Data containing String

    Basically what I am doing is placing an unbound text box named "LOC" within a form named "Equip" that is populated by a query named "EquipSearch".

    I have also placed a command button that on Click it performs

    DoCmd.Requery

    Within my query I have a field named "description" in the criteria I have =Forms![Equip]![LOC]

    Now on my form if I type in Digital Transceiver in the unbound box and hit the Requery command button it will populate the form with all record with the discription Digital Tranceiver.

    But if I type in Digital it will bring back nothing.

    I want to be able to use something sort of like the "Like" comand that will bring back all records that contain the word digital or what ever I type in the unbound text box?

    Please Help I have been beating my head up against the wall for two days now.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Maybe this'll help.....

    In the On Click event of your Command Button:

    Me.Filter = "Description LIKE '*" & Me.LOC & "*'"
    Me.FilterOn = True
    Me.Requery


  3. #3
    Join Date
    Mar 2004
    Posts
    19
    Originally posted by CyberLynx
    Maybe this'll help.....

    In the On Click event of your Command Button:

    Me.Filter = "Description LIKE '*" & Me.LOC & "*'"
    Me.FilterOn = True
    Me.Requery

    I tried this and now it brings back nothing even if I type in an exact match?

    Do I keep everything else the same. Or do I need to revise the criteria in the query?

  4. #4
    Join Date
    Mar 2004
    Posts
    19
    Is there some way I can place a

    Like "*" expression in the criteria pulling the data from the unbound box to be place within the Like " " command?

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by sbook73
    Is there some way I can place a

    Like "*" expression in the criteria pulling the data from the unbound box to be place within the Like " " command?
    You TOTALLY lost me here. Can you post your updated code as it stands?

  6. #6
    Join Date
    Mar 2004
    Posts
    19
    Sorry I ahve attached a sample of what I am trying to do.

    As it is now I can type in an exact match in the box at the top of the form and hit the requery button and it will bring back everything with that exact match.

    But what I want it to do is if I type in just a part of the desciption it will bring back everything with that part in it.

    Example if I type in Digital Tranceiver it will bring back all Digital Transceivers. But if I type in Digital it will bring back nothing.

    If I type in Digital I would like it to bring back everything with Digital in it. Which would be all the Digital Tranceivers and Digital Receivers.

    Hope this clears it up for you. Thanks in advance for the help.
    Attached Files Attached Files

  7. #7
    Join Date
    Nov 2003
    Posts
    1,487
    Attched is the reworked copy of your sample DB. For my example to have work you needed to get rid of your query placed into the form's Record Source propery. The table name should be there. This filter is acting as your query.

    I have also added additional code to your search command button so that it will search whichever search field you enter data into (LOC, Part, or Serial). So now...if you only enter a serial number, the record pertaining to that serial number will be displayed...etc. I have also added code in the command button to clear the search fields once the search is carried out so that you don't have to keep deleting the text to enter a new search.

    Hope this helps

    Attached Files Attached Files

  8. #8
    Join Date
    Mar 2004
    Location
    Adelaide, Australia
    Posts
    32
    Originally posted by sbook73
    Sorry I ahve attached a sample of what I am trying to do.

    As it is now I can type in an exact match in the box at the top of the form and hit the requery button and it will bring back everything with that exact match.

    But what I want it to do is if I type in just a part of the desciption it will bring back everything with that part in it.

    Example if I type in Digital Tranceiver it will bring back all Digital Transceivers. But if I type in Digital it will bring back nothing.

    If I type in Digital I would like it to bring back everything with Digital in it. Which would be all the Digital Tranceivers and Digital Receivers.

    Hope this clears it up for you. Thanks in advance for the help.
    You can try what CyberLynx has suggested, or:

    Change your EquipSearch query by adding LIKE to the criteria and using wildcards in the search textbox.

    ie. Like [Forms]![Equip]![LOC]

    then type: Digital*

    in the Description field on your form, click Run Query.

    Simple, but effective.

  9. #9
    Join Date
    Mar 2004
    Posts
    19

    Talking Thank you very much

    Thank you I tried this and it works great!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •