Results 1 to 9 of 9
  1. #1
    RolandC is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    6

    Calculated field with a Max $ value

    I have a form with a calculated field, but the calculated end result can't exceed $15.00. The first part (the calculated field) is no problem, the problem is making sure it does not go above $15.00.
    ie: I have 3 fields, Field 1 is "LABORTIME" Field 2 is "LABORCOST" Field 3 "SHOPSUPPLIES". LABORCOST is calculated by LABORTIME (Time * Rate). SHOPSUPPLIES are calculated from LABORCOST (LABORCOST*.0625) BUT...most not exceed the $15 max.

  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,186
    Try using an IIf() to test the calculation, return 15 if it's greater.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RolandC is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    6
    Thank you for responding. I have tried with IIF()'s, and a few other combinations with no luck. I've tried Expressions, VBA and probably even Macro's. I'm guessing that it is just the way that I'm writing the code. Expressions and VBA usually let you know when it's not correct. My option to get past the issue was to just have a MsgBox pop-up that tells you to "Enter 15" when the value is >15. But for some reason it won't let me change the value in the form field.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    3,108
    Code:
    =IIf ((LaborCost * 0.0625) > 15,15,LaborCost * 0.0625)
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    RolandC is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    6
    Excellent, thank you. Works perfect.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    3,108
    Quote Originally Posted by RolandC View Post
    Excellent, thank you. Works perfect.
    If you put that as control source, you will not be able to modify that control.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  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,186
    Quote Originally Posted by RolandC View Post
    Thank you for responding. I have tried with IIF()'s, and a few other combinations with no luck. I've tried Expressions, VBA and probably even Macro's. I'm guessing that it is just the way that I'm writing the code.
    FYI, if you just say you've tried things without showing what you've tried, nobody can help you fix it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    RolandC is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    6
    Gotcha, Thanks for the help. Had it working correctly in about 2 minutes.

  9. #9
    RolandC is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    6
    Understood, problem was I tried so many things I couldn't remember what I did and I didn't save any of them because they didn't work. It's all good now. Got the correct expression for the calculated field and it works perfect.

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

Similar Threads

  1. Replies: 4
    Last Post: 02-09-2019, 05:38 PM
  2. Replies: 1
    Last Post: 12-10-2017, 01:47 AM
  3. Replies: 1
    Last Post: 05-22-2017, 05:59 AM
  4. Replies: 2
    Last Post: 12-30-2014, 01:32 PM
  5. Replies: 2
    Last Post: 12-15-2013, 02:29 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