cancel
Showing results for 
Search instead for 
Did you mean: 

Sequential/incremental numbering in a sub report.

Former Member
0 Kudos

I have a list of items in the details section of the main report which are numbered 1,2,3.......etc. The numbers in this list correspond to the item number defined in the database. I then have a list of items in a sub report which are displayed directly below the main list. I would like to continue the numbering, but these items do not have a previously defined item number.

eg,

Main report - details section:

Item No. (note these 4 item number are defined in the database)

1

2

3

4

Sub report - details section:

Item No. (I believe a rformula is required to define these numbers)

5

6

7

Any suggestions would be much appreciated. I am relatively new to Crystal Reports and know very little about generating formulae.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If the issue is carrying the number list from the main report to the subreport and the subreport is called after the detail report is completed, you could use a subreport link, with the last value of the main report item being passed to the subreport. Then you can use that value to initiate a variable that you then incriment for each subreport detail record.

Alternately you could maintain an independent shared variable that counts each main and subreport detail record.

Fuskie

Who hopes that makes sense...

Former Member
0 Kudos

I believe your first suggestion is exactly what I am aiming for, thankyou.

I have placed the sub report in the Report Footer of the main report. How do I know if this sub report is 'called after the detail report is completed'?

I have never used the formula functionality of Crystal Reports - is it relatively simpel to write the code required for your suggestion.

Thanks for the help, I really appreciate it.

former_member260594
Active Contributor
0 Kudos

Crystal Reports will process top down so the details section will process before the Report Footer with the subreport.

If you are linked on the database field that increments in the main report then it will pass the last value to the subreport.

You can then create a formula in the subreport similar to the following;

whileprintingrecords;

Numbervar x;

if onfirstrecord then

x:= x + 1 + {?parameter_field_generated_by_subreport_link}

else x:= x + 1

Former Member
0 Kudos

I get the following error....... any idea why?

This field name is not know.

Details: errorKind

Error in File SingleLevelBOM {DBDBDF£F-551C-A7F0-.........}.rpt:

Error in formula Counting;

'whileprintingrecords

'

This field name is not know.

Details errorKind

I have created the formula and named it "Counting". The formula checker says that there are no errors, but then when I try to actually create a report then the error above is displayed.

Former Member
0 Kudos

Hi Micahel Pearce,

Try creating formula in both main report and sub report like

WhilePrintingRecords;

Shared numberVar x;

x:=x+1;

Raghavendra

Former Member
0 Kudos

Cheers, that actually works perfectly, I just supress the numbers in the main report and display them in the sub report.

That way I can continue sorting the main report details section by the item number.

Answers (0)