yes/no field on report used to filter a query

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

    yes/no field on report used to filter a query

    Hi,

    Ik have a form on which the user can fillin a few field that are used to filter a query to make a report.

    On the form is also a button to run the report in preview mode.

    The fields used are usually drop down lists from which the user then selects one item.

    The query criterium is then:

    Like [Forms]![frm_rapporten].[cmb_rap_am] & "*"

    This line i use to filter the report and if the user did not choose an item from the combobox [cmb_rap_am] it will not filter on thsi field.

    Now, i also have a yes/no field on the form.

    If the yes/no box is checked i would like all records where this field is set to "Yes" to be EXcluded from the recordset.

    If the yes/no box is not checked, there should not be a filter set on this field.

    Does anybody know how to achieve this in te criterium part of a query ?

    Any help would be greatly appreciated !
    Thanks,
    Pierre
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    A little difficult to illustrate without any field/control name but perhaps this may help

    Code:
    Like [Forms]![frm_rapporten].[cmb_rap_am] & "*" AND (CheckField = False OR CheckField <> CheckBox)
    I think this will always show False (No) Recods and only the True (yes) records whan the Checkbox is False (ie only filter 'Yes' records whan checked).

    I think.

    MTB

    Comment

    • Pierkes
      New Member
      • Feb 2013
      • 64

      #3
      Hi MTB,

      Thanks for your reply. However, i don't think this will work for me.

      I have the following checkbox on the form;[yesno_rap_grl]

      Every record in the query has a field called [grl] which can be true or false.

      If the [yesno_rap_grl] is checked on the form, i want the query to list all records except the ones where "[grl] = true"

      If the [yesno_rap_grl] is not checked on the form, i want the query to list alle the records including the records where the field [grl] is true or false

      I hope this is more clear and you have a solution for me ?

      Regards,
      Pierre

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Return it if the field is not the checkbox value or the checkbox is false. That way, if the checkbox is true, it will return the false. Otherwise, it returns everything.
        Code:
        fieldName = Not checkbox Or checkbox = False

        Comment

        • Pierkes
          New Member
          • Feb 2013
          • 64

          #5
          Thanks Rabbit !

          Your solution works fine now !

          Pierre

          Comment

          Working...