Forums
This topic is locked
substracting numbers from diferent recordsets
Posted 25 May 2002 05:11:30
1
has voted
25 May 2002 05:11:30 Alfa Siete posted:
I have filtered one recordset to get a total amount of $ in my field "charges" and did the same to get a total in the payments repeated region...Now i would like to make a basic subbstraction, rest or - operation to get the balance between charges and payments...
any ideas????
Replies
Replied 27 May 2002 20:36:18
27 May 2002 20:36:18 David Behan replied:
You can use the select statement to get the totals of a field for a recordset something like this:
SQL = "SELECT SUM(debits) AS TotalDebits, SUM(credits) AS TotalCredits FROM tbl_accounting"
Then use:
varTotalDebits = RecordSet.Fields.Item("TotalDebits"
.Value
varTotalCrebits = RecordSet.Fields.Item("TotalCrebits"
.Value
varBalance = varTotalDebits - varTotalCredits
Response.Write(varBalance)
Regards,
_________________________
David Behan - www.site-manager.com/af.asp?a=11&l=1tds9p6x2
SQL = "SELECT SUM(debits) AS TotalDebits, SUM(credits) AS TotalCredits FROM tbl_accounting"
Then use:
varTotalDebits = RecordSet.Fields.Item("TotalDebits"

varTotalCrebits = RecordSet.Fields.Item("TotalCrebits"

varBalance = varTotalDebits - varTotalCredits
Response.Write(varBalance)
Regards,
_________________________
David Behan - www.site-manager.com/af.asp?a=11&l=1tds9p6x2
Replied 28 May 2002 04:11:34
28 May 2002 04:11:34 Alfa Siete replied:
Thank you, it worked perfect, love the simplicity...