Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Printing Optional/Multiple Number Parameter Post Reply Post New Topic
Author Message
avaj
Newbie
Newbie


Joined: 26 Sep 2007
Online Status: Offline
Posts: 30
Quote avaj Replybullet Topic: Printing Optional/Multiple Number Parameter
     Posted: 05 Apr 2011 at 6:12am
I'm using Crystal 2008 with Oracle DB
 
I have an optional number parm that can accept multiple entries.  I want to print this in the header or "All" if they didn't enter anything.
 
This formula works fine if something is entered in the parm but gives me an error when nothing is entered.  The error "Parameter has no value"
 
I've tried putting an if hasvalue check in front but it still does not like it.
 
Any help is appreciated.
 
My ultimate goal is to either print the word "All" or the actual parm values. 
 
 
numbervar counter;
stringvar display;
for counter := 1 to count({?Fare Instrument}) do (
display := display + totext({?Fare Instrument}[counter],0,"") + ", ");
left(display, len(display)-2);
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 05 Apr 2011 at 7:15am
the problem is the parameter itself.
It doesn't accept null values nor empty strings.

To deal with this, you should set the default value to a single space.
IP IP Logged
avaj
Newbie
Newbie


Joined: 26 Sep 2007
Online Status: Offline
Posts: 30
Quote avaj Replybullet Posted: 05 Apr 2011 at 7:27am
I did try setting the default to a space but it does not seem to take.   I'm assuming because it is a Number Parm & not a String.  It just keeps reverting back to the first number in the list.  I also tried making 0 the default but just got myself more hosed up.  This is a static number parm with a list of values to choose from.  Thanks
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 05 Apr 2011 at 7:53am
Why not just make it a string field?
IP IP Logged
avaj
Newbie
Newbie


Joined: 26 Sep 2007
Online Status: Offline
Posts: 30
Quote avaj Replybullet Posted: 05 Apr 2011 at 8:09am
For anyone else trying to do this
I was able to get this to work with the following formula:
 
numbervar i;
stringvar x;
if hasvalue({?Fare Instrument}) then
for i := 1 to ubound({?Fare Instrument}) do (
x := x + totext({?Fare Instrument},0,"") + ", "
);
if not hasvalue({?Fare Instrument})
then "All" else
left(x, len(x)-2)
Thanks
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum