Results 1 to 7 of 7
  1. #1
    PeterS is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Posts
    45

    Access 2007 vs Access 365

    Hi

    Please can someone tell me why the following IIF statement works 100% in Access 2007 but not in Access 365?



    Rate%: IIf([overdue]<30="0,1",IIf([overdue] Between 30 And 59="0,15",IIf([overdue] Between 60 And 89="0,2",IIf([overdue]>89="0,25"))))

    The 4th las ) is highlighted in 365 when I try to run it.

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Hi Peter,

    Judging from the decimal numbers in your expression you are running this in a non-US regional settings environment. Can you make sure that both machines have the exact same regional settings and code references and post back the results?

    Cheers,
    Vlad

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    Also as access matures it becomes less tolerant of things like non alpha numeric chars in names - suggest use square brackets around rate%. May not make a difference but better to comply

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,973
    The final IIf has no false statement and isn't needed anyway. Simplify to this:
    Code:
    IIf([overdue]<30="0,1",IIf([overdue] Between 30 And 59="0,15",IIf([overdue] Between 60 And 89="0,2","0,25")))
    Better still use a lookup table with fields RateID, MinValue, MaxValue, RatePercent in place of all these nested IIfs
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    you can simplify further - replace between 30 And 59 etc with <=59. The previous condition will have satisfied <30

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Code:
    Rate%: IIf([overdue]<30 = "0,1",IIf([overdue] Between 30 And 59 = "0,15",IIf([overdue] Between 60 And  89 = "0,2",IIf([overdue]>89 = "0,25"))))
                           /\                                       /\                                        /\                       /\
    You CAN NOT use the equal sign in the expressions.


    This appears to work
    Code:
    Rate2%: IIf([overdue]<30,"0,1",IIf([overdue] Between 30 And 59,"0,15",IIf([overdue] Between 60 And 89,"0,2",IIf([overdue]>89,"0,25","0"))))
    Notice there are NO equal signs in any of the IIF() functions. Also I added the last FALSEPART ("0") of the last IIF() function.




    I also tried the SWITCH() function and it returns the appropriate value:
    Code:
      [Rate%] = Switch([overdue] < 30, "0,1", [overdue] <= 59, "0,15", [overdue] <= 89, "0,2", [overdue] > 89, "0,25")

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,973
    Oops! Brain clearly wasn't in gear when I posted!

    This should work: IIf([overdue]<30,"0,1",IIf([overdue] <= 59,"0,15",IIf([overdue] <=89,"0,2","0,25")))
    though Switch is a bit easier than nested IIfs to do correctly

    but personally I'd still use a lookup table
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 5
    Last Post: 06-05-2015, 10:00 AM
  2. Replies: 2
    Last Post: 04-07-2014, 10:01 AM
  3. Replies: 1
    Last Post: 02-04-2013, 05:52 PM
  4. Export Table in Access 2007 to Multiple Workbooks in Excel 2007
    By hutchinsm in forum Import/Export Data
    Replies: 5
    Last Post: 03-01-2012, 05:23 PM
  5. Replies: 2
    Last Post: 06-18-2011, 09:55 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