Results 1 to 4 of 4
  1. #1
    ali_sh is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    21

    How to use iif in query criteria

    Hello
    I want to add a criteria in a query under field_2 to return value larger than field_1
    I wrote
    Code:
    >field_1
    and that was ok but it is possible for field_1 to be null
    so I wrote following code and got error
    Code:
    IIf(IsNull(field_1);field_2;>field_1))
    Can anyone help me on this?


    Thanks in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Operator symbols cannot be dynamic.

    >Nz(field_1;0)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ali_sh is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    21
    Quote Originally Posted by June7 View Post
    Operator symbols cannot be dynamic.

    >Nz(field_1;0)
    Thank you very much It is a brilliant way but I have positive and negative value in any amount and I also want to use similar way in search form for null text box.
    I have a search form containing a text box and I want to filter a field based on value greater than value entered in text box but return all the field when the text box is empty.
    What do you do in this situation?
    Is there any other way to do this? by using SQL or add a column or using "between" operators or ...?
    I'll be very grateful if you help me on this

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I never use dynamic parameterized query. I use VBA to build filter criteria and apply to form or report. Review http://allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  2. Replies: 4
    Last Post: 08-30-2014, 10:23 AM
  3. Replies: 5
    Last Post: 09-20-2012, 03:27 PM
  4. Replies: 5
    Last Post: 08-02-2012, 09:44 AM
  5. Replies: 1
    Last Post: 07-13-2011, 11:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums