Results 1 to 3 of 3
  1. #1
    mclem is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    1

    IIF Statement Help

    I have a field called DaysOpen. I want to run a query that will result in a Description field based on the following. If the DaysOpen is < 30 days, I want the query result for the field to say "<30 Days" and if the query of the expression of the field is 30-60 days, I want the expression to return the description "30-60 Days". And, if the DaysOpen is greater than 60 days, I want the descriptive text to say ">60 Days".

    So, basically, when I run the query the Description field must come back with 1 of 3 results..."Less than 30 Days", "30-60 Days", or ">60 Days".



    I am pretty sure I use the IIF statement, but can't seem to get it right to come back with the results.

  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,929
    Should really show attempted code.

    DaysOpen is a number value?

    Something like:

    IIf(DaysOpen < 30, "<30 Days", IIf(DaysOpen<=60, "30-60 Days", ">60 Days))

    or

    Switch(DaysOpen <30, "<30 Days, DaysOpen <=60, "30-60Days", True, ">60 Days")
    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
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Try:
    IIf([YourFieldName]="< 30 days","Less than 30",IIf([YourFieldName]="30-60 days","30-60 Days","> 60 Days"))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 5
    Last Post: 11-01-2021, 08:09 AM
  2. Replies: 11
    Last Post: 04-29-2015, 01:38 PM
  3. Using the iif statement
    By Brien in forum Access
    Replies: 4
    Last Post: 11-05-2012, 12:08 PM
  4. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  5. Replies: 7
    Last Post: 08-17-2011, 01:49 PM

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