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!

How do I restart counter at each new group?

Status
Not open for further replies.

jlgjohnson

Technical User
Apr 5, 2004
18
US
I have a formula in a field that sets the line number before each line:

WhilePrintingRecords ;
NumberVar Counter ; Counter := Counter +1;

How do I make this RESTART after each new GROUP?

 
create another formula that set the variable back to 0. Place this formula in the group header.

WhilePrintingRecords ;
NumberVar Counter := 0;

~Brian
 
Thanks Brian! I am having trouble adding this? I have tried to 'format section' but I don't know how to place it in the group header. Thanks for any help you can give me.
 
You want to create a new formula and then drag it into the group header so that it is a new field in the section.

Drag it from the field explorer onto the group header section of the report canvas.

~Brian
 
Brian means that you should use:

Insert->Field Object->Right click formulas and select New and then name it.

This isn't a section formatiing formula.

-k
 
Thank you both for the explanation. The only problem that I came up with is that is starts recounting on each page instead on beginning each group.

How can I modify the formula to restart count at each new group?

Also, is there a good book out there that I can learn how to do these formulas. I am a newbie at this! :)

Jamie
 
I see what you are saying it should do and if I have dragged the formula into the group header it should restart at each new header but it is doing it at each new page. Hmmmm.
 
I just figured it out. I wanted the header on the top of each page. That is what the problem is. If I turn that feature off, then the restart numbering at each group it works. I love that!

Now, can I have both?

Jamie

 
You probably have selected to repeat the group header on each new page which is causing it to reset. If that's the case, you should add:

not(inrepeatedgroupheader);

into the formula for the reset.
 
Thanks midearth! You are right, I do have that selected to repeat group header. The new formula that I have inserted is:

WhilePrintingRecords ;
NumberVar Counter := 0;
not(inrepeatedgroupheader);

however, it is still restarting on every page.

What am I doing wrong?
 
Try redoing the formula like this:

WhilePrintingRecords;
NumberVar Counter;
If not(inrepeatedgroupheader) then Counter:=0

That should work, however, I've got a huge report running right now and it's locked down my CR while it's reading records so I haven't verified.
 
Another option would be to move the formula to the Group Footer to aviod having to work those little details out with the Repeated Group Header.

~Brian
 
Good suggestion. Once I get Group Headers in my mind, I keep forgetting there's also a footer. That should do the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top