Results 1 to 8 of 8
  1. #1
    Pabs is offline Novice
    Windows 8 Access 2007
    Join Date
    Sep 2014
    Posts
    4

    Query IIf Statement - Best Way?

    Hi there, I'm new to not only this forum but all forums!
    I need some help and advice on the best way to do a calculation please.

    I'm creating a "master" query that will support a number of Forms and Reports.
    I need the query to calculate a value based on a maximum limit as follows:

    Part 1
    IF [TotalMiles] < 10,001
    THEN ([TotalMiles] * £0.45)



    Part 2
    IF [TotalMiles]>=10,001
    THEN I need a value calculated up to an including the 10,000 miles point (at £0.45)

    I can do Part 1 but its Part 2 I really struggling with (its probably very easy but my brain has gone into melt down!)

    I hope the above makes sense.
    Many thanks in anticipation.

    Pabs

  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,652
    Are you saying that the miles above 10000 are at a different rate? Or? Perhaps some sample values and the expected result would help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Pabs is offline Novice
    Windows 8 Access 2007
    Join Date
    Sep 2014
    Posts
    4
    Hi Paul
    Yes there are 2 different rates.
    First 10,000 calculated at £0.45, 10,001 and above at £0.25.
    I've got to show separately the 10,001 and above.
    So for example total of 11,000 would be 10,000 * £0.45 = £4,500, 1,000 * £0.25 = £250.
    Cheers
    Pabs

  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,652
    So for part 2 it's the amount less 10000 *.25 plus 4500.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Pabs is offline Novice
    Windows 8 Access 2007
    Join Date
    Sep 2014
    Posts
    4
    Paul
    Thanks for this.
    I don't think I have explained my issue too well.
    I've already catered in another field monies for 10,001 and above miles at £0.25 rate.
    I'm just trying to ascertain the "iif statement" for just returning the maximum value of £4,500 in the "£0.45 field".
    I need to have two fields to show the both values.
    Regards
    Pabs

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Iif(Field>10000,4500, Field * .45)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Pabs is offline Novice
    Windows 8 Access 2007
    Join Date
    Sep 2014
    Posts
    4
    Paul
    Many thanks
    I knew it was simple but total brain failure on my part!
    Regards
    Pabs

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem, and welcome to the site by the way!
    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. Query IIf statement help
    By mike760534211 in forum Queries
    Replies: 5
    Last Post: 01-13-2014, 07:51 PM
  2. IIF Statement in query
    By mariposanegra225 in forum Queries
    Replies: 7
    Last Post: 10-24-2012, 02:15 PM
  3. 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
  4. Replies: 3
    Last Post: 07-10-2012, 05:23 AM
  5. If then statement in query
    By ronnie4 in forum Queries
    Replies: 1
    Last Post: 01-20-2009, 10:49 AM

Tags for this Thread

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