Solved

Crystal Reports Suppress part of Address Field if the value is null

Posted on 2016-09-28
2
58 Views
Last Modified: 2016-09-28
Hello,

I am working with Crystal Reports 11.  I am writing a formula to combine 3 address fields together.  However, one of the fields contains null values.  When it does contain a null value I want the extra space to go away.  

This is how the database looks:

Address1                     Address2               Address3
10 Main Street            Suite 5                    Boston, MA, 02118
20 Pleasant Street                                      Medford, MA, 02125

There is no Address 2 for the second line.

So my formula is this:

{Test.Address_1}+
ChrW(13)+
(If IsNull({Test.Address_2}) then
"" else {Test.Address_2})
+ChrW(13)
+ {Test.Address_3}

Result for Line 1:

10 Main Street
Suite 5
Boston, MA, 02118

Result for Line 2
20 Pleasant Street

Medford, MA, 02125

I want to remove the blank space between "20 Pleasant Street" and "Medford, MA, 02125" for the second result.

Thanks for any help,

Mike
0
Comment
Question by:Michael Graham
2 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 41821043
Try it this way

  {Test.Address_1} +  ChrW(13) +
 (
    If IsNull({Test.Address_2})  then
          "" 
    else 
         {Test.Address_2}  + ChrW(13)
)
 + {Test.Address_3}

Open in new window


Another way would be using what you have

Replace( {Test.Address_1}+
 ChrW(13)+
 (If IsNull({Test.Address_2}) then
 "" else {Test.Address_2})
 +ChrW(13)
 + {Test.Address_3}, ChrW(13) + ChrW(13), ChrW(13))

Open in new window


Another method

  {Test.Address_1} +  ChrW(13) +
 (
    If NOT  IsNull({Test.Address_2})  then
         {Test.Address_2}  + ChrW(13)
)
 + {Test.Address_3}

Open in new window


mlmcc
0
 

Author Closing Comment

by:Michael Graham
ID: 41821048
Tried the first formula and it was perfect.  Awesome.  Thank you so much.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question