Results 1 to 4 of 4
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Error In IIF Loop

    Hi All



    Code:
    IIf(([Session_ID]="Evening") And (([Time_Out]-[Time_In])*24)>=3,0.125,([Time_Out]-[Time_In])) AND IIf((([Time_Out]-[Time_In])*24)>=4,0.166666666,([Time_Out]-[Time_In])) AND IIf(([Level_Of_Unit]="F0") And (([Time_Out]-[Time_In])*24)>6,0.25,([Time_Out]-[Time_In]))
    I tried above code. its not working. How to correct this and get as below mentioned formula.

    i want to run the loops separate. Like Below

    IIF([Expression],[True],[False]) AND IIF([Expression],[True],[False]) AND IIF([Expression],[True],[False])

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    What do you think the result of that would be? Break it out and you will get something like
    Code:
    3 And 4 And .25
    Which makes no sense.
    You would be better writing these complicated types of If statements into a function - pass in the fields you need to check and call that in your query.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Perhaps you are looking for nested IIf() : IIf([expression], True, IIf([expression], True, IIf([expression], True, False)))

    IIf([Session_ID]="Evening" And ([Time_Out]-[Time_In])*24>=3, 0.125, IIf([Level_Of_Unit]="F0" And ([Time_Out]-[Time_In])*24>6, 0.25, IIf(([Time_Out]-[Time_In])*24>=4, 0.166666666, [Time_Out]-[Time_In])))
    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.

  4. #4
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Thnks alot for your support guys,

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

Similar Threads

  1. compile error do without loop
    By AccessHelp12 in forum Access
    Replies: 34
    Last Post: 01-03-2014, 10:59 AM
  2. Error loop when I misscode in a function?
    By stumped in forum Programming
    Replies: 5
    Last Post: 09-27-2012, 01:25 AM
  3. Error with Do While Loop
    By Icewolf0927 in forum Programming
    Replies: 2
    Last Post: 06-11-2012, 10:47 AM
  4. Replies: 8
    Last Post: 05-16-2011, 06:01 PM
  5. Error: Loop without Do
    By eric.opperman1@gmail.com in forum Programming
    Replies: 4
    Last Post: 01-25-2011, 02:37 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