Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running total or formula variation.

Status
Not open for further replies.

fergman

Technical User
Oct 19, 2000
91
US
This is one of those things I've spent to much time on and still can't solve, so here goes:

I have an age field, calculated using this formula:
Code:
WhileReadingRecords;

DateTimeVar Birth := {Abha7105_93005.MceHdr_BirthDate};
DateVar CurDate := CurrentDate;

If (Month(CurDate)*100) + Day(CurDate) >= (Month(Birth)*100) + Day(Birth)

Then Year(CurDate) - Year(Birth)

Else  Year(CurDate) - Year(Birth)-1

I have 3 groups, the last one is the age.
The age is broken out into 5 categories (but not grouped by these categories) with a different formula:

Code:
shared numbervar ageGroup0;
shared numbervar ageGroup18;
shared numbervar ageGroup30;
shared numbervar ageGroup45;
shared numbervar ageGroup65;

whileprintingrecords;

Select {@Age}
    Case 0 to 17 :
        ageGroup0 := ageGroup0 + 1
    Case 18 to 29 :
        ageGroup18 := ageGroup18 + 1
    Case 30 to 44 :
        ageGroup30 := ageGroup30 + 1
    Case 45 to 64 :
        ageGroup45 := ageGroup45 + 1
    Case 65 to 999 :
        ageGroup65 := ageGroup65 + 1

As you can see from above I'm attempting a manual running total and that does work, but I don't know how to reset it on group change (for group totals). And that is the problem. I need to reset this thing on group change, or have a second total for just the group. help! :)
 
So what are these other groups and where are you displaying this formula?

If you're displaying at some group level, then in that group header place:

shared numbervar ageGroup0:=0;
shared numbervar ageGroup18:=0;
shared numbervar ageGroup30:=0;
shared numbervar ageGroup45:=0;
shared numbervar ageGroup65:=0;

-k
 
I actually just came up with a way to solve this. Using a running total and the formula field built into it instead of a manual running total. it seems to be doing most everything I need. Thanks for the response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top