Results 1 to 7 of 7
  1. #1
    accessgm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    10

    Query based off of text in a "description" field

    Hello,



    A column in one of my tables has a lot of text. It is a “description” field.

    I would like the ability to create a query based off of logic relating to
    what text is contained in this field.

    Here is an example of some of the logic (using colors as an example):

    -Color is “red” or “blue” and “black”
    -Cannot have colors “green”, “yellow”, ”purple”, “pink”, “brown”, “teal”

    I am unsure of how to write this in the “criteria” section of the
    “description” field in my query. I’ve tried multiple times with no success.
    Any assistance is appreciated!!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Name of field is 'description'?

    The field content is a narrative, something like: "Calico yellow and black with white socks."

    Use LIKE operator.

    (LIKE "*red*" OR LIKE "*blue*" OR LIKE "*black*") AND NOT LIKE "*green*" AND NOT LIKE "*yellow*" AND NOT LIKE "*purple*" AND NOT LIKE "*pink*" AND NOT LIKE "*brown*" AND NOT LIKE "*teal*"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    accessgm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    10
    Thanks for the reply and I see how you responded given my request but I have somewhat of a twist in my logic needed.

    Using the terms I’m using, here is the wording of the criteria needed:

    Print or MPDL and FIN AD1 or FIN:AD1. Cannot have LCT, 3H/P,ECOPY, FIN AD2, FIN:AD2, S1, S2.

    Here is what I put in the criteria field but it’s not returning what’s needed according to the criteria.

    Like "*PRINT*" Or Like "*MPDL*" And Like "*FIN AD1*" Or Like "*FIN:AD1*" And Not Like "*LCT*" And Not Like "*3H/P*" And Not Like "*ECOPY*" And Not Like "*FIN AD2*" And Not Like "*FIN:AD2*" And Not Like "*S2*" And Not Like "*S1*"

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Based upon your description of the haves, it is not clear if you mean:
    1. Print or MPDL or FIN AD1 or FIN:AD1
    2. Print or MPDL and (FIN AD1 or FIN:AD1)
    3. Print or MPDL or FIN:AD1 and (FIN AD1)

    These are obviously different and will give different results. Please clarify. Also, you indicate that it is not giving the expected results. Perhaps a few sample records and expected results shown would be beneficial. What is specifically wrong with the results you are getting? It would help to solve the issue, otherwise we are throwing darts while blindfolded at a target we cannot see.

  5. #5
    accessgm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    10
    I will try to post some sample output. However your #2 is how the logic needs to be stated...2. Print or MPDL and (FIN AD1 or FIN:AD1....I think this is what is throwing me off b/c I don't have it written or closed off properly. Can you state how your #2 would be written in the "criteria" field within the query???

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Try:

    (Like "*PRINT*" Or Like "*MPDL*") And (Like "*FIN AD1*" Or Like "*FIN:AD1*") And Not Like "*LCT*" And Not Like "*3H/P*" And Not Like "*ECOPY*" And Not Like "*FIN AD2*" And Not Like "*FIN:AD2*" And Not Like "*S2*" And Not Like "*S1*"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    accessgm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    10
    Working well!!! Thank you and to the others for the replies!!

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

Similar Threads

  1. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  2. Replies: 1
    Last Post: 08-23-2012, 08:32 AM
  3. Replies: 3
    Last Post: 10-14-2011, 04:50 PM
  4. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  5. Populating a "Text" field in a Report
    By two_smooth in forum Reports
    Replies: 20
    Last Post: 02-19-2010, 11:25 AM

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