Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Thanked 0 Times in 0 Posts

    Subtracting in Access (access 2000)

    I'm trying to do a calculation in access that will allow a user to receive a discount in one field and show the results in another. The form looks like this. Having a hard time figuring out the line total. It's giving me a the wrong amount. The employee discount is $.20 and the price is $2.27 for example.. Thanks

    Bound text box [UnitPrice] - Bound text box [EmployeeDiscount] x Bound text box [Quantity] =
    Bound text box [LineTotal]

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Subtracting in Access (access 2000)

    Normally, you shouldn't store calculated values in a table, but in situations such as the one you describe it may be necessary. There are parentheses missing in your expression.

    Is EmployeeDiscount an amount or a percentage?

    You'd use the After Update event of the UnitPrice, EmployeeDiscount and Quantity text boxes to store the recalculated value in LineTotal, e.g.

    Private Sub Quantity_AfterUpdate()
    Me.LineTotal = (Me.UnitPrice - Me.EmployeeDiscount) * Me.Quantity
    End Sub

    The above assumes that the discount is an amount. If it is a percentage such as 15 standing for 15%, use

    Me.LineTotal = Me.UnitPrice * (1 - Me.EmployeeDiscount / 100) * Me.Quantity

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts