Results 1 to 8 of 8
  1. #1
    MAFuser is offline Novice
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    3

    Question IIf function Not Returning Correct Calculation


    Hi,

    I'm trying to use Access to calculate some invoices, this involves the sale of individual items and bulk items. I want Access to calculate whether to charge customers the bulk price, or the standard price on orders automatically based on the quantity entered.

    For my "Actual Item Cost" field, I used the Iif statement:

    IIf([Quantity Purchased]>=[Bulk Minimum Quantity],[Bulk Price],[Standard Price])

    to try do this but the field only ever returns a value of 1.

    For the sake of the example, Quantity purchased is 16, bulk minimum quantity is 15, bulk price is $40, and standard price is $50. They are in my "invoice" table and bulk minimum order quantity, bulk price, and standard price are all look-up fields to my "products" table.

    I've searched as well as I can on the forum but can't find a similar situation. Any ideas?

    Thanks in advance.

  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
    Where exactly do you have that? It seems okay from what I can see, so context may be important. Returning 1 makes it sound like it's returning a Boolean or something.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MAFuser is offline Novice
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    3
    Thanks for the quick reply! I haven't used any booleans except to tell whether the item is in stock or not, but that isn't included on this table. Here's a picture of the table so far if that is what you mean by context (I'm quite new to this)

    Click image for larger version. 

Name:	Access.jpg 
Views:	9 
Size:	139.1 KB 
ID:	21641

  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
    So that calculation is in a query? A calculated field? Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    MAFuser is offline Novice
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    3
    Its in a table and I plan to add a form to be able to easily add to it in the future

    Click image for larger version. 

Name:	Access2.jpg 
Views:	9 
Size:	111.3 KB 
ID:	21642

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    For my "Actual Item Cost" field, I used the Iif statement:
    Where is this "field"? When I see this, I think table. Not a good idea to calculate values in a table field. If you mean form control, report control or query field, you should mention it so we know we're dealing with a calculated control or a query field.

    pbaldy asked and I don't see where you answered:
    Where exactly do you have that?
    IIf([Quantity Purchased]>=[Bulk Minimum Quantity],[Bulk Price],[Standard Price])
    I agree - looks like it's evaluating to true. Maybe you clarify where the expression is located, and if in code, post code.

    They are in my "invoice" table and bulk minimum order quantity, bulk price, and standard price are all look-up fields to my "products" table.
    If you are trying to pull these values directly from the table with this expression, you cannot do this. We need more info to help solve the issue.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It may need an = in front of it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  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,521
    By the way, Long Integer will not hold the decimal portion of your values.
    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: 5
    Last Post: 07-10-2015, 08:30 AM
  2. Function - Returning a Value
    By dreamnauta in forum Programming
    Replies: 3
    Last Post: 01-05-2012, 03:37 PM
  3. Replies: 0
    Last Post: 04-18-2011, 01:01 PM
  4. Keyboard not returning correct keycode
    By Toots in forum Programming
    Replies: 1
    Last Post: 04-14-2011, 10:31 AM
  5. Returning correct rows in a join/nested query
    By goneaccessing in forum Queries
    Replies: 5
    Last Post: 03-03-2010, 12:21 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