Creating formulas

  • Thread starter Thread starter Nexus
  • Start date Start date
N

Nexus

how do I create a formula to calculate total amount using
both a control (txtNewQty) and a query?
 
in a query you can use Sum(), in control you can use also Sum() - to make
total of some filed of form recordsource, or DSUM() - to sum any table or
query. see online help for more info
 
I want to multiply qty by price per unit using both the
control and the query together. This is what I've done
and it seems to work but how do I then store the value of
txtTotalPrice into the table with field name TotalPrice?

Private Sub cmdTotalPrice_Click()
txtTotalPrice = (DLookup("[qryToolPrice]!
[ToolPrice]", "qryToolPrice", "[qryToolPrice]![ToolID]='"
& [lstGetToolDetail] & "'")) * txtNewQty
End Sub
 
I want to multiply qty by price per unit using both the
control and the query together. This is what I've done
and it seems to work but how do I then store the value of
txtTotalPrice into the table with field name TotalPrice?

Private Sub cmdTotalPrice_Click()
txtTotalPrice = (DLookup("[qryToolPrice]!
[ToolPrice]", "qryToolPrice", "[qryToolPrice]![ToolID]='"
& [lstGetToolDetail] & "'")) * txtNewQty
End Sub
 
instead of storing a total price (you can do it usung update query) i
suggest you to make a query which returns total price as calculated value
sum(ToolPrice * Qty)

--
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com


Nexus said:
I want to multiply qty by price per unit using both the
control and the query together. This is what I've done
and it seems to work but how do I then store the value of
txtTotalPrice into the table with field name TotalPrice?

Private Sub cmdTotalPrice_Click()
txtTotalPrice = (DLookup("[qryToolPrice]!
[ToolPrice]", "qryToolPrice", "[qryToolPrice]![ToolID]='"
& [lstGetToolDetail] & "'")) * txtNewQty
End Sub

-----Original Message-----
in a query you can use Sum(), in control you can use also Sum() - to make
total of some filed of form recordsource, or DSUM() - to sum any table or
query. see online help for more info
--
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com






.
 
Back
Top