Sub Total Calculation & Accept Numeric Value only (1 Viewer)

postingart

New member
Local time
Tomorrow, 02:21
Joined
Jun 27, 2021
Messages
17
hello
i want to calculate TOTAL in text field run time . like
TOTAL = ( price x Quantity ) - Discount

i want when press key then calculate run time and only accept numeric value
Private Sub GTotal()
Me.txtGTotal.Value = (Val(Me.txtPrice.Value) * Val(Me.txtQuantity.Value)) - Val(Me.txtDiscount.Value)
End Sub

Private Sub Form_Load()
Me.txtDiscount = 0
Me.txtPrice = 0
Me.txtQuantity = 0
End Sub


Private Sub txtDiscount_Change()
GTotal
End Sub

Private Sub txtPrice_Change()
GTotal
End Sub
Private Sub txtQuantity_Change()
GTotal
End Sub
 

Attachments

  • qSample.accdb
    552 KB · Views: 95

Ranman256

Well-known member
Local time
Today, 17:21
Joined
Apr 9, 2015
Messages
4,337
you cannot add/multiply letters, you only do math on numerics.
but you dont need the .VALUE, just use only the txtboxs.
But if a box is NULL you will get nulls. Prevent with NZ

Me.txtGTotal=NZ(Me.txtPrice,0) * NZ(Me.txtQuantity,0) - NZ(Me.txtDiscount,0)
 

postingart

New member
Local time
Tomorrow, 02:21
Joined
Jun 27, 2021
Messages
17
you cannot add/multiply letters, you only do math on numerics.
but you dont need the .VALUE, just use only the txtboxs.
But if a box is NULL you will get nulls. Prevent with NZ

Me.txtGTotal=NZ(Me.txtPrice,0) * NZ(Me.txtQuantity,0) - NZ(Me.txtDiscount,0)
not calculate run time, i want then i change single value then total change automatically
 

Users who are viewing this thread

Top Bottom