Sara Hedtler
asked on
Calculating Sales Tax
I've tried to create a Form to Calculate Sales and Taxes, but I'm not able to get the form to work. Super new to vba, off and on for a few years and its now become imperative for me to get this done. This is the code i have so far.
Private Sub txtSalesTax_Change()
Me.txtSubtotal.Text = Val(Replace(txtSalesPrice. Text, "$", "")) * Val(Replace(txtSalesTax.Te xt, "%", "")) / 100
End Sub
Private Sub txtSubtotal_AfterUpdate()
Me.txtSubtotal.Value = Format(txtSubtotal.Text, "$0,00")
End Sub
Private Sub txtSalesTax_AfterUpdate()
Me.txtSalesTax.Text = Val(txtSalesTax.Value) / 100
Me.txtSalesTax.Text = Format(txtSalesTax, "Percent")
End Sub
Private Sub txtTotalSale_Values()
Dim dbltxtTotalSale As Double
On Error Resume Next
dbltxtTotalSale = CDbl(txtSubtotal.Value)
dbltxtTotalSale = dbltxtSubtotal + CDbl(PriceIncrease.Value) - CDbl(txtSubtotal.Value)
dbltxtTotalSale = dbltxtTotalSale + CDbl(PriceIncrease.Value)
txtTotalSale.Value = dbltxtTotalSale
txtTotalSale = Format(txtTotalSale, "$0.00")
End Sub
Private Sub txtSalesTax_Change()
Me.txtSubtotal.Text = Val(Replace(txtSalesPrice.
End Sub
Private Sub txtSubtotal_AfterUpdate()
Me.txtSubtotal.Value = Format(txtSubtotal.Text, "$0,00")
End Sub
Private Sub txtSalesTax_AfterUpdate()
Me.txtSalesTax.Text = Val(txtSalesTax.Value) / 100
Me.txtSalesTax.Text = Format(txtSalesTax, "Percent")
End Sub
Private Sub txtTotalSale_Values()
Dim dbltxtTotalSale As Double
On Error Resume Next
dbltxtTotalSale = CDbl(txtSubtotal.Value)
dbltxtTotalSale = dbltxtSubtotal + CDbl(PriceIncrease.Value) - CDbl(txtSubtotal.Value)
dbltxtTotalSale = dbltxtTotalSale + CDbl(PriceIncrease.Value)
txtTotalSale.Value = dbltxtTotalSale
txtTotalSale = Format(txtTotalSale, "$0.00")
End Sub
the line below looks weird...
if the SalesTax is based on Subtotal, you can update the SalesTax in txtSubtotal_AfterUpdate() event.
like:
Me.txtSalesTax.Text = Val(txtSalesTax.Value) / 100
if the SalesTax is based on Subtotal, you can update the SalesTax in txtSubtotal_AfterUpdate() event.
like:
Private Sub txtSubtotal_AfterUpdate()
Me.txtSubtotal.Value = Format(txtSubtotal.Text, "$0,00")
Me.txtSalesTax.Text = Format(txtSalesTax, "Percent")
End Sub
Private Sub txtSalesTax_AfterUpdate()
End Sub
ASKER
Thank you! I've attached the workbook to see.
ASKER
I thought i had attached it, but apparently not.
sales---tax.xlsm
sales---tax.xlsm
ASKER
It wasn't working for me. Not sure if I was using the right code.
yea, it may not worked at this moment, but can you tell us the logic of calculations so we can build the right codes
ASKER
I think i almost have it, its just the totals not working. sales---tax--revised-5-5-17.xlsm
can you tell us the logic behind the calculation of Total Sale?
we can't just guess what you needed.
we can't just guess what you needed.
ASKER
I need the total to calculate from Subtotal, Sales Price and Price Increase to sum.
if you have:
Price Increase : $20.00
Sales Price: $100.00
Sales Tax: 3.00%
Sub Total: $3.60
what is the expected Total Sale?
Price Increase : $20.00
Sales Price: $100.00
Sales Tax: 3.00%
Sub Total: $3.60
what is the expected Total Sale?
ASKER
$123.60
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Could you please outline your process a little more?
For example, which text boxes are you allowing users to enter data into? Which ones are locked? Do you have any other controls on the form? Is your form bound to a table or recordset?
-Tala-