Using database fields in a calculation
am 06.05.2005 13:39:20 von Shoraz Hosein
I need to use some database fields for calculations but I an not certain
about the syntax. For example I want the Onhand value to subtract the
Qty Committed to sales.
In a seperate cell in a table I want the balance to show up.
The fields are
(1)<%=(rs_stock.Fields.Item("Qtyonhand").Value)%>
(2)<%=(rs_stock.Fields.Item("Qtycommitsales").Value)%>
All I want to do is subtract the (2) from (1)
Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Re: Using database fields in a calculation
am 06.05.2005 16:56:19 von unknown
1 way:
iOnhand = CLng("0" & rs_stock.Fields.Item("Qtyonhand").Value)
iSold = CLng("0" & rs_stock.Fields.Item("Qtycommitsales").Value)
iBalance = iOnHand - iSold
The important thing is that you CLng your values so that the script knows
it's dealing with numeric values. Also, the whole "0" & nonsense is to
handle any case where your query is returning nulls (which it hopefully
isn't).
You could also return this in your query
SELECT Qtyonhand, Qtycommitsales, Qtyonhand-Qtycommitsales AS Qtybalance
FROM...
Ray at work
"Shoraz Hosein" wrote in message
news:%23$m$%23AjUFHA.3344@TK2MSFTNGP10.phx.gbl...
>
> I need to use some database fields for calculations but I an not certain
> about the syntax. For example I want the Onhand value to subtract the
> Qty Committed to sales.
> In a seperate cell in a table I want the balance to show up.
> The fields are
> (1)<%=(rs_stock.Fields.Item("Qtyonhand").Value)%>
> (2)<%=(rs_stock.Fields.Item("Qtycommitsales").Value)%>
>
> All I want to do is subtract the (2) from (1)
> Thanks.
>
>
> *** Sent via Developersdex http://www.developersdex.com ***