Link to home
Start Free TrialLog in
Avatar of mco32
mco32

asked on

If statements in Crystal Reports

Hi

Can someone help with the formula below.  I am trying to get the address to show in one text box.  If all fields have data, all show in the text box on the report but if one is blank then from the blank field on does not display (eg. if add3 = "" then nothing else will show on the report after add2, but if its present all data shows.

Please help,

CSTR({Customer.customer_Add1}) &
IF CSTR({Customer.customer_Add2})="" THEN "" ELSE CHR(13) & CSTR({Customer.customer_Add2}) &
IF CSTR({Customer.customer_Add3}) ="" THEN "" ELSE CHR(13) & CSTR({Customer.customer_Add3}) &
IF CSTR({Customer.customer_Town}) ="" THEN "" ELSE CHR(13) & CSTR({Customer.customer_Town}) &
IF CSTR({Areas.area_Name}) ="" THEN "" ELSE CHR(13) & CSTR({Areas.area_Name}) &
IF CSTR({Customer.customer_Postcode}) ="" then "" ELSE CHR(13) & CSTR({Customer.customer_Postcode})
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mco32
mco32

ASKER

Slight change and it worked perfectly
Thank you so much

Local StringVar outString;

outString := CSTR({Customer.customer_Add1});
IF CSTR({Customer.customer_Add2}) <> "" THEN
     outString := outString & CHR(13) & CSTR({Customer.customer_Add2});
IF CSTR({Customer.customer_Add3}) <> "" THEN
     outString := outString & CHR(13) & CSTR({Customer.customer_Add3}) ;
IF CSTR({Customer.customer_Town}) <> "" THEN
     outString := outString & CHR(13) & CSTR({Customer.customer_Town});
IF CSTR({Areas.area_Name}) <> "" THEN
     outString := outString & CHR(13) & CSTR({Areas.area_Name}) ;
IF CSTR({Customer.customer_Postcode}) <> "" then
     outString := outString & CHR(13) & CSTR({Customer.customer_Postcode});
outString
Good catch.  That is the problem with not being able to run the code.

mlmcc
Avatar of mco32

ASKER

Thank you again - never would have got this without you