Results 1 to 2 of 2
2005-10-10, 17:30 #1
- 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]
2005-10-10, 17:52 #2
- Join Date
- Mar 2002
- Thanked 29 Times in 29 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
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