Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

864 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now