Re: Using database fields in a calculation
- From: "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial>
- Date: Fri, 6 May 2005 10:56:19 -0400
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" <shoraz@xxxxxxxxx> wrote in message
news:%23$m$%23AjUFHA.3344@xxxxxxxxxxxxxxxxxxxxxxx
>
> 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 ***
.
- Follow-Ups:
- Re: Using database fields in a calculation
- From: Shoraz Hosein
- Re: Using database fields in a calculation
- References:
- Using database fields in a calculation
- From: Shoraz Hosein
- Using database fields in a calculation
- Prev by Date: Re: Help with Query
- Next by Date: Re: Using database fields in a calculation
- Previous by thread: Using database fields in a calculation
- Next by thread: Re: Using database fields in a calculation
- Index(es):
Relevant Pages
|