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

Embedding an if statement in Ubound function

Status
Not open for further replies.

robercr12

Programmer
Aug 11, 2009
75
US
hi,
I am using the following which I got from tek-tips FAQ -- its really awesome. I have been wanting to do this.

Now one of my parameters shows {ALL} as a default parameter, all i want to do is get rid of the curly brackets and simply show ALL.

Is there a way to put an If else statement in the code below?

whileprintingrecords;
stringvar Output:="";
numbervar Counter;
For Counter := 1 to ubound({?Department }) do(
if minimum({?Department }[Counter])= maximum({?Department }[Counter]) then
Output:= Output & minimum({?Department }[Counter])& ","
else
Output:= Output & minimum({?Department }[Counter])& " to "& maximum({?Department }[Counter])& " , "
);
left(Output,len(Output)-1)

I am using CR version 10

Thanks
Rob
 
You're doing the task using a variable. It would be better to get the same result using running totals and formula fields. Take a bit of time and learn how they work. (The use of Crystal's automated totals is outlined at FAQ767-6524.)

I'm not sure what you want is even possible in a variable. Since no one else has answered it probably isn't.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
whileprintingrecords;
stringvar Output:="";
numbervar Counter;
For Counter := 1 to ubound({?Department }) do(
if minimum({?Department }[Counter]) = "{ALL}" then "All" else
if minimum({?Department }[Counter])= maximum({?Department }[Counter]) then
Output:= Output & minimum({?Department }[Counter])& ","
else
Output:= Output & minimum({?Department }[Counter])& " to "& maximum({?Department }[Counter])& " , "
);
left(Output,len(Output)-1)

This assumes that {?Department} is a string with an option {ALL} in the value list. Not sure why you are using the curly brackets in the picklist if you don't want them displayed.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top