Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    May 2004
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Not equal returned from IIf for query criteria (2002)

    I have a table with a column that will only contain Yes or No. I want users to be able to run a report and specify to show either records with Yes or records with No or all records. I have a combobox limited to the choices All, Yes, and No with All as the default.

    My idea to make this happen was to use the following IIF( ) in the query as criteria

    IIf([forms]![frmReport]![cboEntered]="All","<>All",[forms]![frmReport]![cboEntered])

    The idea is if the user specifies All, use <>All as the criteria (and show everything since All is not actually stored in the table). If they choose anything other than All (Yes or No) use that as the criteria. My idea seems great but I can't get it to work. I thought that maybe I needed to somehow pass <>All with quotes as <>"All" but I can't get the IIf( ) function right.

    Any help is appreciated. Thanks,

    Kevin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Not equal returned from IIf for query criteria (2002)

    Try
    <code>
    Like IIf([Forms]![frmReport]![cboEntered]="All","*",[Forms]![frmReport]![cboEntered])
    </code>
    If the user selects "Yes" or "No", Like will act the same as = in the condition, but if the user selects "All", the condition becomes Like "*"

    Note: if the field may contain null (blank) values, it's different.

  3. #3
    Lounger
    Join Date
    May 2004
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Not equal returned from IIf for query criteria (2002)

    Hans,

    Thanks so much! It works great.

    Kevin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •