CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    3

    Question Get distinct comma separated list of values in Crystal Reports Footer

    I have a report with many detail lines. For example:

    Horse 123
    Cow 453
    Pig 123
    Sheep 546

    I need to put a summary at the bottom of the report, which in this case would read:

    123, 453, 546

    A comma separated list of values, WITHOUT repeats.

    I don't care if I need to use sql expressions, Crystal Reports code, or vb code to do it, but I have to be able to print a comma separated list of distinct values.

    I have tried doing this with an sql expression, and it will not work in the report but will from SQL Query Analyzer directly on the DB. Can a Crystal Reports sql expression field use the full range of SQL query commands? Or is it just a subset? What are the limits? Help on any of these questions would be much appreciated. I'm using Crystal Reports 10, btw.

  2. #2
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Get distinct comma separated list of values in Crystal Reports Footer

    To do that, you have to Group your data and create 2 formulas:

    The first one, let's say @comma_field:
    Code:
    whileprintingrecords;
    stringvar names;
    names := names & ", " & {table.field};
    Place it in your GroupHeader section which you can suppress; the formula will return you next:
    , Jules, Christina, Paul


    and the secondformula, let's call it @final (or whatever you like):
    Code:
    whileprintingrecords;
    stringvar names;
    Mid(names, 3);
    Place it in your Report Footer section.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured