Results 1 to 5 of 5
  1. #1
    M3RiM is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2020
    Posts
    3

    Lightbulb Use IIf condition to return < (less than) or > (bigger than)

    Hello everyone

    I can't understand what is the problem in my IIF condition.

    By typing this condition in Criteria
    IIf([Forms]![Formname]![CheckBox]=True; =>[Forms]![Formname]![Textbox]-1; <[Forms]![Formname]![Textbox]-1)
    it doesn't return anything

    If I tipe in the Criteria field only the value_if_true


    =>[Forms]![Formname]![Textbox]-1
    it returns exactly what I want

    the same with value_if_false
    it works great

    but in the IIF condition it doesn't work

    please help

    thanks and best regards
    Merim

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,891
    The logical operators cannot be dynamic.

    I would not use dynamic parameterized query. I would use VBA to build criteria string 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.

  3. #3
    M3RiM is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2020
    Posts
    3
    really not happy to hear that.

    I though to do it in VBA but in this case my db would requires more queries to filter data to use them in the VBA.
    though to do it easily in the query, but unfortunatelly I was unlucky

    OK, thanks anyway.
    i will try to solve it somehow

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    try the following

    have a column populated with [Forms]![Formname]![CheckBox] (you can untick the show option since it does not need to be returned in your query
    on the first criteria line put =>[Forms]![Formname]![Textbox]-1 - and on the checkbox column put True
    on the second criteria line put <[Forms]![Formname]![Textbox]-1) - and on the checkbox column put False

    if you have other criteria you will need to repeat on the second line

    Not tested but I think another way would be just for one line

    (=>[Forms]![Formname]![Textbox]-1 AND Forms]![Formname]![CheckBox]=True) OR (<[Forms]![Formname]![Textbox]-1 AND Forms]![Formname]![CheckBox]=False)

  5. #5
    M3RiM is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2020
    Posts
    3
    Thanx Ajax

    this is it

    The OR solved my problem. It works as I wish
    It would never fell on my mind

    Thanks a lot !!!

    Best regards

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

Similar Threads

  1. Replies: 2
    Last Post: 06-13-2018, 03:59 AM
  2. Replies: 7
    Last Post: 06-25-2015, 01:03 PM
  3. Query to find condition and return field name
    By kagoodwin13 in forum Queries
    Replies: 3
    Last Post: 01-15-2014, 02:04 PM
  4. Bigger DB vs Performances
    By Fabdav in forum Database Design
    Replies: 1
    Last Post: 09-17-2011, 05:34 PM
  5. Replies: 7
    Last Post: 08-03-2011, 08: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