Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

13 Experts available now in Live!

Get 1:1 Help Now