Solved

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

Posted on 2016-09-28
2
52 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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