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

How can I combine fields to form one address line 1

Status
Not open for further replies.

timoteo

Technical User
Sep 17, 2002
72
US
I a using Crystal Reports 7 and I want to combine several fields related to addresses(HouseNum, Fraction, Street, AptNum) into one address line in the details section. If I just insert the database fields and line them up, the result is messy because some the fields maybe blank and the values are of different lengths.

I also tried concatenating the fields using a formula. My formula looks some thing like this:

{SubMain.HouseNum}+" "+{SubMain.Fraction}+" "+{SubMain.Street}+" "+{SubMain.AptNum}

This approach works reasonably well, however if one of the fields is blank, the whole formula returns no value.

Is there anyway to combine these fields in a clean presentable way.
 
Try this formula that checks each field, and only appends to the result if there's a value:
Code:
(if (isnull({SubMain.HouseNum}) or {SubMain.HouseNum} = "") then "" else {SubMain.HouseNum} + " ")
+
(if (isnull({SubMain.Fraction}) or {SubMain.Fraction} = "") then "" else {SubMain.Fraction} + " ")
+
(if (isnull({SubMain.Street}) or {SubMain.Street} = "") then "" else {SubMain.Street} + " ")
+
(if (isnull({SubMain.AptNum}) or {SubMain.AptNum} = "") then "" else {SubMain.AptNum})
-dave
 
vidru,

Thanks for the help. Your solution was right on!

Timoteo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top