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

Trying to get a running total field to reset on a formula 1

Status
Not open for further replies.

laker42

Programmer
Feb 11, 2003
60
US
We have a running total field that is counting the number of records on a page. It is putting 54 records on a page. We need the running total field to reset after each 54 records. We tried editing the running total field and set it to reset on the formula: count(Records) = 54. This is not working correctly. On the first page the count field says 54 and on the second page it shows 108 instead of 54. We want this to show 54 for all of the pages except for the very last page. Any ideas on what we are doing wrong? I think it must be a simple thing that we are missing. Any ideas would be appreciated!

Thanks!
John
 
You can do it manually without using the running total.


Add a formula named clearreccount to the detail to clear the count when it reaches 54:

whileprintingrecords;
shared numbervar myrecs;
if myrecs = 54 then myrecs := 0

Add a formula to the detail to count the records:

EvaluateAfter ({@clearreccount});
whileprintingrecords;
shared numbervar myrecs := myrecs + 1

and then display the count using this formula to show the count:

whileprintingrecords;
shared numbervar myrecs;
myrecs

 
Thanks for the suggestion, I will give it a try. After posting the question, I wondered if I could use the mod function to accomplish what I want to do. Any idea?

Thanks!
John
 
If the point is to get a page break after 54 records, you could use the following formula in the x+2 area for "page break after":

remainder(recordnumber,54)= 0

-LB
 
LB-
We can get the page break after 54 records to work. We are trying to reset a running total field after each page. So the running total field will evaluate to 54 records for each page except the last page.

John
 
If you use the remainder function to do the page break, then the running total will automatically reset after 54 records if you put a reset formula in the page header:

//{@reset} for page header:
whileprintingrecords;
numbervar counter := 0;

//{@counter} for details:
whileprintingrecords;
numbervar counter := counter + 1;

-LB

 
LB,
Thanks for the suggestion. It worked great!

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top