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

simple numbering of groups 2

Status
Not open for further replies.

johnstrang

Technical User
Dec 8, 2003
60
CH
Hi,

I have a simple problem which I cannot understand.

Using CR 8.5, I simply want to number the groups in a report - so required output is
1 First Group Name
detail lines

2 Second Group Name
detail lines

3 Third Group Name
detail lines

etc.

In RH I have a formula init_line_nr
Code:
numbervar line_nr := 1 ;

In GF1 I have formula inc_line_nr
Code:
numbervar line_nr := line_nr + 1 ;

In GH1 I have formula line_nr
Code:
numbervar line_nr ;

Problem is that variable line_nr is being reset to 1 for each group. I have tried several options, without any success, including defining the variable line_nr as global.

Why is it doing this? Surely it should increment at the end of every group.

Any information will be gratefully received.

John
 
It's an evaluation timing issue. Precursor each of your formulas with:
whileprintingrecords;

your RH would look lie this:
Code:
whileprintingrecords;
numbervar line_nr := 1

Mike
 
Try using the special field GroupNumber instead of using formulas. If that won't work for you, adjust your formulas like this:
[tt]
//ReportHeader formula
WhilePrintingRecords;
numbervar line_nr := 1 ;

//GroupHeader formula
WhilePrintingRecords;
numbervar line_nr;

//GroupFooter formula
WhilePrintingRecords;
numbervar line_nr := line_nr + 1;
[/tt]
-dave
 
Mike,

That's perfect - as soon as I saw your answer I realised that was the problem. I should have known it myself [sad]
 
Dave,

I didn't know about group_number - that also works perfectly.
Many thanks,
John
 
One caution on the GroupNumber field. If you have multiple layers of groups, each grouping gets counted.

Using the GroupNumber field:
GH1 GroupCounter = 1
GH2 GroupCounter = 2
GH3 GroupCounter = 3
GH2 GroupCounter = 4


Using your method:
GH1 GroupCounter = 1
GH2
GH3
GH2 GroupCounter = 2




Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top