Use (or) & (and) comand in same time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aks 2010
    New Member
    • Aug 2010
    • 13

    #1

    Use (or) & (and) comand in same time

    Hello

    i have three field used for filter the subform
    i built the code of filter
    but i am so weak in VB so i need to put all code of filter together to i can filter by any one at time or used all in same time to filter or two of thim at time

    like:
    code
    (or)
    Code
    (or)
    code

    -------

    code
    (and)
    code
    (and)
    code


    i hope my question is clear:)


    thanks in advance....
  • liimra
    New Member
    • Aug 2010
    • 119

    #2
    Solution/

    You can use If Then in a way where the filter will be based on the populated fields.

    Code:
    If [A] Is Not Null And [B] Is Null And [C] Is Null
    'set the action you want WHERE THE FILTER is [A]
    End If
    IF [A] Is Not Null And [B] Is Not Null And [C] Is Null
    'set the action you want WHERE THE FILTER is [A] & [B]
    End If
    IF [A] Is Not Null And [B] Is Not Null And [C] Is Not Null
    'set the action you want WHERE THE FILTER is [A] & [B] & [C]
    End If
    IF [A] Is Null And [B] Is Not Null And [C] Is Null
    'set the action you want WHERE THE FILTER is [B] & [C]
    End If
    IF [A] Is Null And [B] Is Not Null And [C] Is Null
    'set the action you want WHERE THE FILTER IS [B]
    End If
    IF [A] Is Null And [B] Is Null And [C] Is Not Null
    'set the action you want WHERE THE FILTER is [C]
    End If

    Regards,
    Ali

    Comment

    • Aks 2010
      New Member
      • Aug 2010
      • 13

      #3
      thank you Ali for help me

      i will not forget your favor with me

      Comment

      • liimra
        New Member
        • Aug 2010
        • 119

        #4
        //

        We are all here to help. Glad it worked for you mate.

        Regards,
        Ali

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          To be fair, this approach can get very cumbersome very quickly. It will work for very simple scenarios but is not a good approach going forward.

          Have a look at Cascaded Form Filtering to see how this whole subject can be handled more flexibly and more simply.

          Comment

          • liimra
            New Member
            • Aug 2010
            • 119

            #6
            ?

            I just wanted to offer a simple/easy to understand approach. However, it is indeed not the best approach for filtering. I didn't try NeoPa's approach but think it must be a better one.

            It is worth mentioning that one good thing about Access is that even with little knowledge you can make good achievements (working around).

            Regards,
            Ali

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32669

              #7
              Originally posted by Ali
              Ali:
              It is worth mentioning that one good thing about Access is that even with little knowledge you can make good achievements (working around).
              That's very true, and all suggestions are welcome.

              Comment

              Working...