borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Crystal Report Font InCompatibility.)Next Topic (Problem with crystal report and farsi language!) New Topic New Poll Post Reply
AndreaVB Forum : Reporting tools : NEWBIE! Formula in CR8 stops at first condition ?
Poster Message
erikfleischer
Level: Trainee

Registered: 07-12-2004
Posts: 2

icon NEWBIE! Formula in CR8 stops at first condition ?

I'm having an adress, that can consist of up to 4 lines.
Raraly all 4 lines are used so I wanted to make an adressfield by piecing together the adress lines.  

The problem is however if any of the IF contions are false,  (the adressline is empty) then the formula does not return anything.

Can anyone give me a clue to this ?

Tia

Erik


if Length({KUNDE.Z_LINIE1}) > 0 then
adr1  =  {KUNDE.Z_LINIE1} & chr(10)
else
adr1 = ""
end if

if Length({KUNDE.Z_LINIE2}) > 0 then
adr2  =  {KUNDE.Z_LINIE2} & chr(10)
else
adr2  ""
end if

if Length({KUNDE.Z_LINIE3}) > 0 then
adr3 =  {KUNDE.Z_LINIE3} & chr(10)
else
adr3 = ""
end if

if Length({KUNDE.Z_LINIE4}) > 0 then
adr4  =  {KUNDE.Z_LINIE4}
else
adr4 = ""
end if

formula =  adr1 & adr2 & adr3 & adr4

07-12-2004 at 04:26 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: NEWBIE! Formula in CR8 stops at first condition ?

What does mean EMPTY? Is it null value or zero-string? Maybe you should check if it is a NULL value. I am not positive how CR append strings to null value. In VB, for instance, when you want to assign some value to string variable from text type database field, you should do it like this

str=rs("somefield") & ""


This was no error will occur if this field has NULL value. So if this logic can be used in CR, then this might work

adr1  =  {KUNDE.Z_LINIE1} & ""
adr2  =  {KUNDE.Z_LINIE2} & ""
adr3 =  {KUNDE.Z_LINIE3} & ""
adr4  =  {KUNDE.Z_LINIE4} & ""

if Length(adr1) > 0 then
adr1  =  adr1 & chr(10)
end if

if Length(adr2) > 0 then
adr2  =  adr2 & chr(10)
end if

if Length(ad3) > 0 then
adr3 =  adr3 & chr(10)
end if

formula =  adr1 & adr2 & adr3 & adr4


____________________________
If you find the answer helpful, please mark this topic as solved.

08-12-2004 at 01:17 AM
View Profile Send Email to User Show All Posts | Quote Reply
erikfleischer
Level: Trainee

Registered: 07-12-2004
Posts: 2
icon Re: NEWBIE! Formula in CR8 stops at first condition ?

Of course! Your'e right! I should check for NULL not the length of the string!

Silly me, I think I was confused by CR lack error message on this. (And that I'm very new to CR)

Thanks a lot

Erik

08-12-2004 at 09:26 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Reporting tools : NEWBIE! Formula in CR8 stops at first condition ?
Previous Topic (Crystal Report Font InCompatibility.)Next Topic (Problem with crystal report and farsi language!) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder