Query criteria yes/no field problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pierkes
    New Member
    • Feb 2013
    • 64

    #1

    Query criteria yes/no field problem

    Hi,

    Iám having problems with a criteria in a query. The field is a yes/no field.

    I have a yes/no field on a form which i can check of uncheck. The field is called [yesno_rap_grl].

    In the query criteria i have;

    Code:
    IIf([Forms]![frm_rapporten].[yesno_rap_grl]=True;False;([tbl_trajecten].[tr_eig_grl])=True Or ([tbl_trajecten].[tr_eig_grl])=False)
    The result i get is;

    When [yesno_rap_grl] is checked i get all the records except the ones that have the field [tr_eig_grl] true.
    THIS WORKS FINE

    When [yesno_rap_grl] is not checked i get all the records that have the field [tr_eig_grl] true.
    THIS IS NOT WHAT I WANT

    When [yesno_rap_grl] is not checked i want to get all the records regardless if the field [tr_eig_grl] is true of false.

    Does anybody have an idea on how to write the right line in the "criteria" portion of the query ?

    Thanks in advance for your help !!!
    Best regards,
    Pierkes
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Pierkes,
    Use this, and test it for <>0
    Code:
    iif([Forms]![frm_rapporten].[yesno_rap_grl]=True,-1- [tr_eig_grl] ,-1)
    Or if you prefer something more straight-forward
    Code:
    iif([Forms]![frm_rapporten].[yesno_rap_grl]=True,iif([tr_eig_grl] ,false,true),true)
    Jim

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      What you say you want, what you say is happening, and what the code does gives completely different outcomes.

      Please fill out this logic grid.
      Code:
      [yesno_rap_grl] [tr_eig_grl] result
      checked         checked      ?
      checked         unchecked    ?
      unchecked       checked      ?
      unchecked       unchecked    ?

      Comment

      • Pierkes
        New Member
        • Feb 2013
        • 64

        #4
        Originally posted by Rabbit
        What you say you want, what you say is happening, and what the code does gives completely different outcomes.
        Please fill out this logic grid.
        Code:
        [yesno_rap_grl] [tr_eig_grl] result
        checked         checked      - select all records where tr_eig_grl is not checked
        checked         unchecked    - select all records where tr_eig_grl is not checked
        unchecked       checked      - Select all records
        unchecked       unchecked    - Select all records
        Last edited by Rabbit; Apr 3 '14, 03:53 PM. Reason: Fixed tags.

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          For that outcome, jimatqsi's solution will work for you.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            The information you posted indicates that [tr_eig_grl] is irrelevant and has no bearing on what is shown. Is that a correct understanding or is your last post in error (See specifically lines #2 & #3)?

            Comment

            Working...