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

    IIF Loop

    Hi


    Code:
    IIf((IIf(((Sum([Actual_Hours]))*24<20),(Sum([Actual_Hours])),CStr((Int(Sum([Actual_Hours])*24) & ":" & Round(((Sum([Actual_Hours])*24)-Int(Sum([Actual_Hours])*24))*60,1)))))>=20,20,(IIf(((Sum([Actual_Hours]))*24<20),(Sum([Actual_Hours])),CStr((Int(Sum([Actual_Hours])*24) & ":" & Round(((Sum([Actual_Hours])*24)-Int(Sum([Actual_Hours])*24))*60,1))))))
    Is the above code correct? if not what is the correct way to use?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If it works it's correct, if not then it isn't.

    sorry, couldn't resist. I'm not on a computer, but it looks like you're trying to format a time interval? That formula is difficult to read, understand, and debug. I'd create a VBA function that took the interval as an input and returned the desired result. It would be easier to follow and you'd be able to call it from anywhere.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hi

    what i want to do is, if sum of no_of_hours is greater than 20 hours then show result as 20 else show sum of no_of_hours

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That appears to be doing more than that, but if just that it's simply:

    IIf(Sum([Actual_Hours])> 20, 20, Sum([Actual_Hours]))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 9
    Last Post: 03-07-2017, 02:49 PM
  2. Replies: 12
    Last Post: 06-05-2015, 04:27 PM
  3. Replies: 13
    Last Post: 08-20-2014, 09:17 AM
  4. Replies: 17
    Last Post: 04-07-2014, 07:48 PM
  5. Replies: 3
    Last Post: 03-10-2013, 07:04 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