2nd Post - Recordset Help needed

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Have a recordset which produces a list of invoices
between Data A and Date B. One of the fields in that
recordset has the invoice value.

How would I be able to get a value/calculate for the the
sum of that field?

Thanks in advance

Richard
 
Richard,

In sert the following piece of code somewhere in your procedure, where the
recordset is opened:

SumOfValues = 0
rs.movefirst
Do Until rs.EOF
SumOfValues = SumOfValues + rs.Fields("Value")
rs.MoveNext
Loop

In the above I have assumed that the recordset is called rs and the value
field name is Value. Change to match the actual names. Afetr the loop is
executed, variable SumOfValues will contain the total value.
Declare SumOfValues as Double at the beginning of your procedure, and make
sure the recordset is closed and set to Nothing (the latter goes also for
the object it belongs to, if one is created) at the end of your procedure.

HTH,
Nikos
 
Back
Top