Question

Im using Crystal Reports,and I have an output like this:

     NumberId         ART_No          InkColor
     ------------------------------------------
     0010             23003             BLUE
     0010             23003             RED
     0010             23003             GREEN
     0013             23004             ORANGE
     0013             23004             PINK
     0013             23004             WHITE
     0015             23007             GREEN
     0015             23007             PINK

Is there any possible way how can I make the output (in Crystal Reports) be like this even not using SQL Script:

     NumberId         ART_No          InkColor
     ------------------------------------------
     0010             23003             BLUE, RED, GREEN
     0013             23004             ORANGE, PINK, WHITE
     0015             23007             GREEN, PINK

Thanks

Was it helpful?

Solution

You'll need to do a few things to achieve that.

  1. Create a group for NumberId.

  2. Suppress the Group Header.

  3. Create a FormulaField; we'll call it @ColorReset. It should contain the following code:

    WhilePrintingRecords;
    stringVar Colors := "";
    

    Place this in your group header. This will reset the Colors stringVar every time the Group Header is hit.

  4. Suppress the Detail section.

  5. Create another FormulaField; we'll call it @ColorAppend. It should concatenate the values like this:

    WhilePrintingRecords;
    stringVar Colors := Colors + ", " + {YourTable.InkColor};
    

    Place this in your detail section. This will build your color string every time the Detail section loops.

  6. Create one more FormulaField to show the colors, called @ColorsShow. It will display the colors like this:

    WhilePrintingRecords;
    StringVar Colors;
    
    RIGHT(Colors, LEN(Colors) - 2);    // Strip off the leading comma and space
    

    Place this in your group footer, along with the NumberId and ART_No


Your end result should be:

---------- Group Header 1 ----------
/////////// @ColorReset ////////////

------------- Details --------------
////////// @ColorAppend ////////////

---------- Group Footer 1 ----------
[NumberId] [ART_No] [@ColorsShow]

It looks a little initmidating, but it's pretty straightforward.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top