Multiple Criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beantown256
    New Member
    • Sep 2008
    • 1

    Multiple Criteria

    Hi everyone,

    I'm a relative newbie to access so hopefully this will be easy for everyone.

    I'm trying to limit the field in a query so that it does not include lines where their value is equal to 3, 5, 16,or 17.

    I type

    <>3
    5
    (separate lines)

    and I've tried

    <>3 Or 5

    Both ways, the only variable that is taken away from the field is the 3. If I make the 5 right after the <>, then it is only the 5 that get taken away. What am I doing wrong and how can I fix this? Thanks!
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Place this in the Criteria box for your field in the Query Grid:

    Not Like "[3,5,16,17]"

    just like that, with quatation marks and brackets.

    Welcome to Bytes!

    Linq ;0)>

    Comment

    • DonRayner
      Recognized Expert Contributor
      • Sep 2008
      • 489

      #3
      Originally posted by beantown256
      Hi everyone,

      I'm a relative newbie to access so hopefully this will be easy for everyone.

      I'm trying to limit the field in a query so that it does not include lines where their value is equal to 3, 5, 16,or 17.

      I type

      <>3
      5
      (separate lines)

      and I've tried

      <>3 Or 5

      Both ways, the only variable that is taken away from the field is the 3. If I make the 5 right after the <>, then it is only the 5 that get taken away. What am I doing wrong and how can I fix this? Thanks!
      not 3 and not 5 and not 16 and not 17

      or you could do it like this

      <>3 and <>5 and <>16 and <>17

      You need to and the conditions togeather.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        Please remember to provide a meaningful Title for any threads started (Please Use Appropriate Titles for New Threads!). This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

        Administrator.

        PS. Linq has provided exactly the correct method to use.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          Oops!

          Reading it again I'm not so sure :S That is based on string only filtering and may well not (I don't think it does in truth) work in this situation.

          Try instead "Not In(3,5,16,17)"

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            Originally posted by NeoPa
            Reading it again I'm not so sure :S That is based on string only filtering and may well not (I don't think it does in truth) work in this situation.
            Not sure what you mean, Ade!

            Not Like "[3,5,16,17]"

            works whether the field is Numeric (which I originally tested, based on the original post) and if the field is defined as Text, which I just now checked..

            Linq ;0)>

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32656

              #7
              I tested it earlier and it didn't work for me. If you say it does I'll try it again then.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32656

                #8
                I knocked up a quick table with numbers 1 - 15 in a field.

                I knocked up a quick query with criteria = "Like '[1,7,13]'"

                The results returned were :
                1; 3; 7

                Comment

                Working...