Results 1 to 5 of 5
  1. #1
    fcp is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    8

    Post How to get matching words in string of characters.

    Hi,

    I have a field called Produce that has the following values/data.



    PRODUCE

    Box of apples
    Box of Pineapples
    Crates of Apples

    My query criteria is as follows to pick up apples only!

    Like "*" & [PRODUCE:] & "*"


    When I type in "apples" the criteria also returns "Pineapples" in the record. Is there a way in Access to pick up only "apples" and ignore "pineapples" in the selected record?

    Thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Try " apples" a space before the a

  3. #3
    fcp is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    8
    I guess I can tell users to do that. I was hoping there is a way for Access to get the exact words within a group of string rather than grouping the characters. So for example in a string of "box of apples" there is a wildcard to pick only individual apples as a whole word rather than picking up "pineapples" as well because "pineapples" contains the string "apples."

    If there is no way then its Ok.

    Thanks

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Well look at it this way. You want to find an exact string - That isn't the issue. The reality is that there are 2 words within your field values that contain "apples". In order to find an exact match you have to search for the exact match using a unique string.
    That is the search you want to achieve.

    You want to find the exact target and only that target, so in your case you must use
    " apples". As you have found for yourself, "apples" will find all occurrences of apples, whether it is "bag of apples","case of Pineapples" or "snapples" or crabapples....

    I notice you are a relatively new poster, welcome and continue learning by doing.

    Here is a link to Crystal's material which is an excellent collection of good practices and instruction. http://www.accessmvp.com/strive4peace/

  5. #5
    fcp is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    8
    I think I got the logic behind the solution you given. Thanks again!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-30-2011, 09:38 AM
  2. Replies: 5
    Last Post: 03-10-2011, 02:19 PM
  3. String Matching
    By tuna in forum Programming
    Replies: 1
    Last Post: 05-16-2010, 12:22 PM
  4. how select middle characters on string ???
    By ayman.maher in forum Queries
    Replies: 1
    Last Post: 04-27-2010, 09:29 AM
  5. replace characters in a string
    By blazixinfo@yahoo.com in forum Access
    Replies: 6
    Last Post: 08-06-2009, 03:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums