Results 1 to 6 of 6
  1. #1
    jdhaldane is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    6

    Calculations in Query

    Hi every one:
    I have query based on “Items in shop” table containing a “Client’s price” field for each item. This query calculates several percentages based on the “Client’s price” field.
    Second Hand items Shop
    This a 5% on the client items price to keep the item at the shop


    Ad fee 5%: [Client's price]*0.05
    Then I have a form with “Control Source” the mentioned Query with the following fields:
    Client’s price:
    Ad fee 5%:
    The calculation is working perfect, every time you change the value from “Client’s price” calculates the 5% perfectly.
    The Issue:
    I want the expression in the query to set the percentage to be set to 0% if the “Client’s price” value is under 20. Only calculate the percentage if the “Client’s price” value is over 20.
    Thank you very much for your help.

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You can use an IIF() function in the query.

    The general form is as follows:
    IIF( expression, true part, false part)


    In your case, the function would look something like this:
    IIF([Client's price]>20,[Client's price]*0.05,0)

    As a general practice, it is best not to have spaces or special characters (',#, @, etc.) in your table of field names.

  3. #3
    jdhaldane is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    6

    Smile That was really quick, thank you

    I’m impressed, it works perfectly well. Thank you very much...
    Here comes the next Issue:
    In the same Query I have
    “Com 10%: [easyAds price]*0.2” – Calculates 20% on the price
    I want the expression to calculate 35% on the price if the price is under 20, and to calculate 20% if it’s over 20.
    I do appreciate very much your help.

  4. #4
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You can use the same approach again with the IIF() function:
    Something like this:
    IIF([easyAds price]<20, [easyAds price]*0.20, [easyAds price]*0.35)


    What do you want to happen if [easyAds price]=20? As currently written, the above expression will use 0.35 if the [easyAds price]=20. If that is not what you want then you will have to change the < to <=.

  5. #5
    jdhaldane is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    6

    Smile Thank's for your help it works!

    This is fantastic, I'm just starting to get just to write expressions...

    Thank's again.

  6. #6
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome. Good luck with your database.

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

Similar Threads

  1. Calculations in reports
    By bvanscoy678 in forum Reports
    Replies: 4
    Last Post: 08-05-2010, 06:27 AM
  2. MSACCESS Query with calculations?
    By Masterfinn in forum Queries
    Replies: 10
    Last Post: 02-24-2010, 10:51 AM
  3. Calculations in Access
    By dominick in forum Access
    Replies: 0
    Last Post: 07-28-2009, 07:39 AM
  4. Subform calculations
    By foureyes in forum Forms
    Replies: 4
    Last Post: 07-27-2009, 08:20 AM
  5. Time calculations
    By jimandann in forum Programming
    Replies: 2
    Last Post: 02-18-2009, 12:27 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