2nd Post - Recordset Help needed

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
 
N

Nikos Yannacopoulos

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top