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

looping in crystal reports

Status
Not open for further replies.

rreddy01

Programmer
Apr 18, 2012
15
US
I have this below formula in my main report.
this formula is getting all the county names into a variable called federalcountyname but the thing is the county names are repeating, means they are getting duplicated.

For Ex: they are counties called A,B,C,D ETC.

WHEN I USE THIS FORMULA I AM GETTING SOMETHING LIKE THIS
A,B,C,A,A,D,(HERE THE VALUES ARE REPEATING INSTEAD OF THIS I NEED TO GET UNIQUE VALUES like A,B,C,D)

whileprintingrecords;
Shared stringvar federalcountyname;

IF NOT({REFCOUNTY.REFCOUNTY_NM} LIKE ['D*']) THEN
(

if length(federalcountyname) = 0 then federalcountyname := federalcountyname + (if {PROPOSAL.FUNDTYPE} = 'FED' then GroupName ({@County_Name}))
else if ( federalcountyname <> (if {PROPOSAL.FUNDTYPE} = 'FED' then GroupName ({@County_Name}))) then
federalcountyname := federalcountyname + "," +(if {PROPOSAL.FUNDTYPE} = 'FED' then GroupName ({@County_Name}));
)


This below formula counts the no of counties and adds county or counties at the end depending on the count.

whileprintingrecords;
Shared stringvar federalcountyname;

if length(federalcountyname) <> 0 then
(
if InStr(federalcountyname, ",") = 0 then federalcountyname + " " + "COUNTY"
else federalcountyname + " " + "COUNTIES"
)

Please help me out with the first formula about how to get rid of those duplicates.

Any help is greatly appreciated.

Thanks,
rreddy
 
It's not really looping, and Crystal is a report tool rather than a full computer language. You have to slot your own code into its cycles.

For your specific problem, you need to Group by values A,B,C,D. Suppress detail lines and show necessary fields in a group header or footer.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Thanks for your reply.

i have created a variable called federalcountyname, trying to get all the county names in that variable separated by commas.but when i do that i am getting duplicates.

the output should be A,B,C,D but instead of this i am getting A,B,C,A,A..etc


Thanks,
rreddy
 
//{@accum}:
whileprintingrecords;
Shared stringvar federalcountyname;
IF NOT({REFCOUNTY.REFCOUNTY_NM} LIKE ['D*']) and
{PROPOSAL.FUNDTYPE} = 'FED' and
instr(federalcountyname,{@County_Name})=0 then
federalcountyname := federalcountyname + {@County_Name}+",";

//{@display}:
whileprintingrecords;
Shared stringvar federalcountyname;
if length(federalcountyname) <> 0 then
(
if ubound(split(federalcountyname,","))=1 then
left(federalcountyname,len(federalcountyname)-1) + " " + "COUNTY" else
left(federalcountyname,len(federalcountyname)-1) + " " + "COUNTIES"
)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top