Results 1 to 5 of 5
  1. #1
    soldat452002 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    16

    Multiiple IIFs Statement

    Hello


    My expressions are not working correctly. Some of the dates are not calculating correctly. Can someone let me know if im using my expressions correctly?

    ---field properties
    [Status] (30 Day Notification, 15 Day Notification, 1 day Expired, 30 Day Expired)
    [Date Created] Date stored as text

    ---This is my Expression to convert TEXT to Date for Date Created field.
    DateCreated: DateValue([Cases].[Created On])

    ---Then get the Difference between Dates
    SLA: DateDiff("d",[qry_Cases].[DateCreated],Now())


    --- This expression is to look at many Statuses and give me the dates the cases have been opened and if out of compliance.
    SLA_Status: IIf([qry_Cases].[Status]='30 Day Notification' And [SLA] <='16',"Within SLA",IIf([qry_Cases].[Status]='15 Day Notification' And [SLA] Between '14' And '31',"Within SLA",IIf([qry_Cases].[Status]='1 Day Expired Notification' And [SLA] Between '31' And '61',"Within SLA",IIf([qry_Cases].[Status]='30 Day Expired Notification' And [SLA] Between '62' And '80',"Within SLA","Out of SLA"))))

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    One thing. Since DataDiff returns a numeric value (the number of days), remove the single quotes you have around the numbers. Single quotes are text qualifiers, so you would not use them around numeric values, i.e.
    Code:
    And [SLA] <=16,
    Also, in your SLA calculation, note that Now() has a time component, which will lead to a fractional component in the SLA value that gets returned. If you do not want that, use Date() instead of Now().

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well for starters, the SLA calculation will return a numeric value, so the values in your IIf() should not be surrounded by quotes:

    [SLA] <=16
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    First you say [Date Created] is a text field storing value then you show [DateCreated] as a calculated value. One name has space, the other doesn't. Are these the same field?

    SLA is a number, don't use apostrophe delimiters. Only one IIf needed.

    SLA_Status: IIf(([Status]='30 Day Notification' And [SLA] <=16) Or ([Status]='15 Day Notification' And [SLA] Between 14 And 31) Or ([Status]='1 Day Expired Notification' And [SLA] Between 31 And 61) Or ([Status]='30 Day Expired Notification' And [SLA] Between 62 And 80), "Within SLA", "Out of SLA")
    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.

  5. #5
    soldat452002 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    16
    Thank you all! removing the double quotes fixed the expression.

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

Similar Threads

  1. Nested IIFs?
    By aellistechsupport in forum Programming
    Replies: 7
    Last Post: 03-14-2016, 06:47 PM
  2. Nested IIFs?
    By aellistechsupport in forum Queries
    Replies: 15
    Last Post: 01-29-2016, 03:03 PM
  3. Criteria with IIFs?
    By aellistechsupport in forum Queries
    Replies: 15
    Last Post: 01-25-2016, 12:43 PM
  4. multiiple filter on a split form
    By webisti in forum Forms
    Replies: 1
    Last Post: 04-06-2012, 12:36 PM
  5. Multiple IIfs
    By SueO in forum Reports
    Replies: 1
    Last Post: 08-12-2010, 04:53 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