Cumulative Totals

J

Jim Jones

Some help needed for a VBA novice.

I have a table called Totals which has one field called Count and another
called CumCount. Count contains a series of integers and I need to update
CumCount to show the cumulative total as in the following example

Count CumCount
2 2
4 6
1 7
7 14
10 24

It can't be all that difficult, but I’ve been stuck for the last 2 hours.
Could someone provide me a few lines of code which will populate the CumCount
field for me (and get me going again!)

Any help would be much appreciated.

Jim Jones
Botswana
 
J

John Spencer

With the structure you have there is no way to do this using a query. And
really no way to do it reliably with code.

You have no way to reliably determine the order of the records.

You might be able to populate CumCount as you add new records - depending on
what method you are using to populate Count. If you are entering records
through a form or using code to add one record at a time, then you could get
the sum of all other existing records.

If you need to do this in a report, then you could use a control on the
report to do what you want.
Add a control to the report.
Set its source to Count
Set its running sum to OverAll.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
J

Jim Jones

Dear John

Many thanks for your prompt response.

Clearly it's not as easy as I thought it would be. The report solution
seems the most promising approach - I will try it right away.

Many thanks again

Jim Jones
Botswana
 

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