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

Capturing value once when the value repeats in a string 1

Status
Not open for further replies.

martinjt

Technical User
Aug 1, 2008
34
US
Using Crystal 9 with Oracle. I am using variables to capture names that are associated with a gift record. The string result can have multiple values or the same value repeated. What I need is for the value to show once in the string result.

In the group header I have the reset formula, the details section the accumulate and the footer the show. The result (show) could look like this:

name1, name1, name1, name2, name3

I need it to look like this:

name1, name2, name3

Is there a way to test each record for equal value? I haven't discovered yet a way to test using next or previous without making all the name1 values part of the string be blank.

Hopefully I have given enough information so that my question makes sense.

JT
 
I assume you data looks like this

name1
name1
name1
name2
name3

Ie 5 records and your variable formula scrolls down and adds the names to a text string

You can use two vars

global stringvar previous;
global stringvar list;

Modify your code on lines

If {namefield} <> previous then previous:= {namefield};

If {namefield} <> previous then list:= list &", " &{namefield};

Previous would be reset in group header in same was as list
ie

global stringvar previous:='';


Ian



 
//{@accum}:
whileprintingrecords;
stringvar name;
if instr(name,{table.name}) = 0 then
name := name + {table.name} + ", ";

//{@display}:
whileprintingrecords;
stringvar name;
if len(name)> 2 then
left(name,len(name)-2)

-LB
 
Thanks you two. I tried both and LB's worked perfectly. Thank you LB!!

Ian, yours was very similar to what I was already trying and you're right - that is what my data was looking like.

Thanks again,

JT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top