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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset Record Counts for each new group using variables

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

First, By declaring a variable, I created a formula that displays a record count. Easy enough.

My current formula (in the detail section)is:
WhileReadingRecords;
NumberVar RecordCount;
RecordCount := RecordCount+1

What I want to do is have the count reset itself for each new group. Group A: 1-4 Group B: 1-4, etc. I can do this using a running total, but I would really like to learn how to do it using a variable.

Secondly, I noticed that if I refreshed the report, the displayed counts became out of sync. It would go from 4 to 13 to 9 to 43 etc. Why?

Thanks folks
 
synapsevampire,

I have already tried the formula that you suggested. The result is that all of my records are numbered as 1 instead of being counted.

As for the second part of my original message. After I have created the formula to count the records, if I refresh the report the count is no longer accurate. Instead of numbering from 1-30 lets say, it starts to jump around. Ex. 1-3 then 9 then 13 then 10 or some sporatic numbering sequence.

I am using version 7 if that matters.

 
Your version is fine.

But SynapseVampire said to place the resetting formula in the group header - whereas it sounds to me like you placed it in the detail section after the counting formula.

Do that and then let us know if you're still getting those jumping around shenanigans.

Naith
 
Tell you what, why don't I let you know that you're still getting those jumping around counts instead.

Change whilereadingrecords to whileprintingrecords.

Naith
 
Alright, problem solved.

I did reset the count in the header. That wasn't the problem. What had to be done was change the scope to local.

As for the sporatic counting. Changing "WhileReadingRecords" to "WhilePrintingRecords" did the trick. Although, I am not sure why. Can you tell me

By the way, thanks again for your help.
 
Whileprintingrecords forces the report to process the counter while the records are being printed.

On the other hand, whilereading records forces the count to before this, which can pose problems when it's trying to process on a field which is being processed later than it is.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top