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

Null Values

Status
Not open for further replies.

Crider

Programmer
Aug 4, 2003
13
US
I have formula structured as follows assuming the following values:
FieldA = 'Hello'
FieldB = 'there '
FieldC = 'dude'

IF NOT ISNULL(FieldA) THEN
FieldA + CHR(13) + CHR(10) +

IF NOT ISNULL(FieldB) THEN
FieldB + CHR(13) + CHR(10) +

IF NOT ISNULL(FieldC) THEN
FieldC + CHR(13) + CHR(10)

If none of the fields are NULL then I will get what I
expect:
Hello
there
dude

If FIELDB, for example happens to be NULL then the entire
formula quits from that point on and I end up with
Hello

I want all 3 IF statements to execute whether there is data or not because I want to list any values present in any of the three fields. It seems as if the subsequent IF statements are part of the prior IF structure instead of being entities on their own. Perhaps it's the way I'm concatenating the string together that is causing this, I don't know.

I'm finding that dealing with NULLS in Crystal is sometimes a real pain. Can someone perhaps suggest another approach to what I am doing?

Thank you
 
Try using varilble to collect then display your results.

whileprintingrecords;
stringvar outa:="";
stringvar outb:="";
stringvar outc:="";

IF NOT ISNULL(FieldA) THEN
outa:=FieldA + CHR(13) + CHR(10) ;

IF NOT ISNULL(FieldB) THEN
outb:=FieldB + CHR(13) + CHR(10) ;

IF NOT ISNULL(FieldC) THEN
outc:=FieldC + CHR(13) + CHR(10);

outa + outb + outc





Mike
 
or use just one variable

whileprintingrecords;
stringvar Result := "";

IF NOT ISNULL(FieldA) THEN
Result := Result + FieldA + CHR(13) + CHR(10) ;

IF NOT ISNULL(FieldB) THEN
Result := Result + FieldB + CHR(13) + CHR(10) ;

IF NOT ISNULL(FieldC) THEN
Result := Result + FieldC + CHR(13) + CHR(10) ;

Result;


Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top