Results 1 to 3 of 3
  1. #1
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93

    Calculated fields


    Hello everyone
    I have a query that contains a product, quantity, unit and price fields. All fields pick their values from an underlying table except the price which I need it to be calculated in the query. So I need to multiply the quantity by the price, but I need to use a different formula based on the value of the unit field. For example, if the unit is (Liner Metric) I need to multiply the quantity by 3.81 before multiplying it with the price, but if the unit is (Nos) then I need to multiply the quantity with the price directly. How to do that inside a query?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    something like

    ttlValue:[qty]*[price]*iif([unit]="linearMetric",3.81,1)

    if you have lots of different units, probably better to store them in a table and link to it in your query

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    I think you need to create an expression using the IIF() function.
    if the unit is (Liner Metric)
    Can you explain what this means.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Help with Calculated Fields
    By Jaci in forum Access
    Replies: 1
    Last Post: 04-30-2014, 09:13 PM
  2. Replies: 12
    Last Post: 10-01-2013, 12:59 PM
  3. Calculated fields
    By FinChase in forum Queries
    Replies: 5
    Last Post: 02-02-2012, 06:12 PM
  4. Calculated fields
    By Madmax in forum Forms
    Replies: 1
    Last Post: 06-17-2011, 08:36 AM
  5. Calculated fields
    By graciemora in forum Forms
    Replies: 1
    Last Post: 02-04-2011, 06:07 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