Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Print an address using a formula Post Reply Post New Topic
Author Message
Ronny101
Newbie
Newbie


Joined: 12 Oct 2011
Location: Canada
Online Status: Offline
Posts: 18
Quote Ronny101 Replybullet Topic: Print an address using a formula
    Posted: 27 Oct 2011 at 6:39am
Hi,
I am using Crystal Reports Version 11 and I am trying to print the customer address using the following formula;
 
stringVar address := "";
if (not(isnull({OEHDR.Custaddr1})) and {OEHDR.Custaddr1} <> "")
    then address := {OEHDR.Custaddr1} + " " + chrw(13);
if (not(isnull({OEHDR.Custaddr2})) and {OEHDR.Custaddr2} <> "")
    then address := {OEHDR.Custaddr2} + " " + chrw(13);
if (not(isnull({OEHDR.Custcity})) and {OEHDR.Custcity} <> "")
    then address := address + {OEHDR.Custcity} + " ";
if (not(isnull({OEHDR.Custstate})) and {OEHDR.Custstate} <> "")
    then address := address + {OEHDR.Custstate} + " ";
if (not(isnull({OEHDR.Custzip})) and {OEHDR.Custzip} <> "")
    then address := address + {OEHDR.Custzip} + " ";
if (not(isnull({OEHDR.Custcntry})) and {OEHDR.Custcntry} <> "")
    then address := address + {OEHDR.Custcntry};
address
 
My problem is when Custaddr1 and Custaddr2 are populated only Custaddrs 2 is showing, do you see anythink wrong with the formula?
Thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Oct 2011 at 7:06am
stringVar address := "";
if (not(isnull({OEHDR.Custaddr1})) and {OEHDR.Custaddr1} <> "")
    then address := {OEHDR.Custaddr1} + " " + chrw(13);
if (not(isnull({OEHDR.Custaddr2})) and {OEHDR.Custaddr2} <> "")
    then address := address + {OEHDR.Custaddr2} + " " + chrw(13);
if (not(isnull({OEHDR.Custcity})) and {OEHDR.Custcity} <> "")
    then address := address + {OEHDR.Custcity} + " ";
if (not(isnull({OEHDR.Custstate})) and {OEHDR.Custstate} <> "")
    then address := address + {OEHDR.Custstate} + " ";
if (not(isnull({OEHDR.Custzip})) and {OEHDR.Custzip} <> "")
    then address := address + {OEHDR.Custzip} + " ";
if (not(isnull({OEHDR.Custcntry})) and {OEHDR.Custcntry} <> "")
    then address := address + {OEHDR.Custcntry};
address
IP IP Logged
Ronny101
Newbie
Newbie


Joined: 12 Oct 2011
Location: Canada
Online Status: Offline
Posts: 18
Quote Ronny101 Replybullet Posted: 27 Oct 2011 at 7:12am

Thank you so muchEmbarrassed

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Oct 2011 at 7:23am
fyi crystl  XI has a 'suppress embedded field blank lines' option for text boxes (common tab of the format editor)
you can drag and drop your fields into it and it will remove the unwanted carriage returns
IP IP Logged
Ronny101
Newbie
Newbie


Joined: 12 Oct 2011
Location: Canada
Online Status: Offline
Posts: 18
Quote Ronny101 Replybullet Posted: 27 Oct 2011 at 9:46am
I am sorry, but when I go to Format Field I dont have 'suppress embedded field blank lines' on the common tab
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Oct 2011 at 9:59am

it is not available for your formula field, only if you added a text object and dropped fields into it.


I was just giving an alternative solution to your problem of combining fields into a single text with 'conditional' carriage returns

Edited by DBlank - 30 Jul 2015 at 9:56am
IP IP Logged
Lynette
Newbie
Newbie


Joined: 18 Dec 2014
Online Status: Offline
Posts: 1
Quote Lynette Replybullet Posted: 30 Jul 2015 at 9:42am
Big help for the report I'm building.  THANKS!
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.063 seconds.