cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports: How to concatenate strings to display 'detail' records?

Former Member
0 Kudos

I have two subreports.

Subreport 1:

Detail A: UK

Detail B: USA

Detail C: China

Subreport 2:

Detail A: UK

Detal B: Spain

I would like to have as a resul: China, USA, UK, Spain.

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Isak,

1) Inside Subreport 1, create a formula with this code and place it on the Details Section:

WhilePrintingRecords; 

shared stringvar array arr; 

shared numbervar i; 

if not({Country} in arr) then 

    i := i + 1; 

    redim preserve arr[i]; 

    arr[i] := {Country}; 

); 

arr[i];

2) Create a similar formula in Subreport 2 with this code and place it on the Details Section:

WhilePrintingRecords; 

shared stringvar array arr; 

shared numbervar i; 

if not({Country} in arr) then 

    i := i + 1; 

    redim preserve arr[i]; 

    arr[i] := {Country}; 

); 

arr[i];

3) In the Main report, create a formula to display the results. Place this on the Report Footer:

shared stringvar array arr; 

Join(arr, ', ') ;


-Abhilash

Former Member
0 Kudos

Thank You, It is working as you said.

Is it posible to place the 3rd formula to display the results in the Report Header?

abhilash_kumar
Active Contributor
0 Kudos

Glad it works.

You can place this on the Report Header only if the Subreports are also on the Report header.

-Abhilash

Former Member
0 Kudos

Hi,

Both subreports are in the Report Header, but the result is not displayed in the Report Header even that I place there the 3rd formula.

abhilash_kumar
Active Contributor
0 Kudos

Insert three Report Header sections - a, b and c.

Place Subreport 1 on Report Header a, Subreport 2 on Report Header b and the shared variable formula on Report Header c.

You cannot place the shared variable formula on a section above the one that holds the subreports.

-Abhilash

Former Member
0 Kudos

Wow!

This issue has gone to an advanced level and it Works!

Thank you very much Abhilash!

Answers (0)