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

Create a list of items using WhilePrintingRecords

Status
Not open for further replies.

rosdancer

Programmer
Jul 26, 2002
14
CA
Hi,

I've only been using Crystal Reports for about a month now.
I would like to display a list of strings, or a concat string that is all the values in a field.
The problem is that I want to display them in the group header not in the details.
I've looked at using a running total but think that whileprintingrecords is my best bet.
I'm not sure how I would do that, what kind of syntax would it be.

Thanks

Roslyn
 
well Roslyn you will have to give us a little more detail if this is a hard problem.

There is no problem displaying a field in a Group header if you wish...the question is "Why would you want to do so?"

What is the reason...from a report standpoint?

Give us a sample of the data in each table you are using. Show us a sample of how you want the report to look with real data and identifying the field names of the data and we will guide you as to the type of report you will need.

"WhilePrintingRecords" is used in formulas to control when they are evaluated....If there is no formula then it isn't used.

"a running total" is used for summary actions on the data, for example summing the value of a particular field.

Show us what you are looking for. Jim Broadbent
 
To display all of the values of a field as a concatenated string, you'll need to use a string field, and you'll be limited to 254 chars unless you use multiple strings.

The common approach would be:

Group header:

whileprintingrecords;
global stringvar MyString:="";

Details section:
whileprintingrecords;
global stringvar MyString;
MyString := MyString + " " + {MyTable.MyField}
//note that if you're displaying a non string a conversion
//will be required above

Group Footer:
whileprintingrecords;
global stringvar MyString;
MyString

This is a simple example which shows how the theory works

-k kai@informeddatadecisions.com
 
Thanks synapsevampire, It works great.

One more question if you are up to it.

Can it be done so that there aren't multiple strings.
For example some of my possible fields are names of the people who have worked on the project but if they worked on more than one part then I only want to include them once.
I know that there are pre-defined functions such as instr and strcomp but I don't know which one would be the best to use and how.

Thanks.

Roslyn
 
If you're trying to assure that there aren't dupes within the string, try:

If Instr(MyString, trim({MyTable.MyField})) = 0 then
MyString := MyString + " " + {MyTable.MyField}

in lieu of:

MyString := MyString + " " + {MyTable.MyField}

-k kai@informeddatadecisions.com
 
Thanks synapsevampire, you've been a great help.

Roslyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top