Solved

Suppressing blank lines in an address block

Posted on 2011-03-18
5
452 Views
Last Modified: 2012-05-11
Okay, I've been fooling around with this about an hour. It's time to bring in the experts!

I'm using CR 2008.

I'm trying to suppress blank lines in an address block on a form I'm creating (customer statements). I'm a professional programmer just starting to fool around with CR.

Bad:
===============================
Acme Hardware
123 Easy Lane
(blank)
New York, NY  12345
===============================

Good:
===============================
Acme Hardware
123 Easy Lane
New York, NY  12345
===============================

I've tried to solve this using a formula. I've set it to "Basic Syntax". (See attached)

The formula is returning blanks.

What am I doing wrong?

Thanks for your help.

Jim
dim buf as String

buf = {COMPANIES.COMPANY_NAME}

if Length({COMPANIES.ADDRESS1}) > 0 then 
  buf = buf & Chr(13) & {COMPANIES.ADDRESS1}
end if

if Length({COMPANIES.ADDRESS2}) > 0 then 
  buf = buf & Chr(13) & {COMPANIES.ADDRESS2}
end if

if Length({COMPANIES.ADDRESS3}) > 0 then 
  buf = buf & Chr(13) & {COMPANIES.ADDRESS3}
end if

if Length({COMPANIES.CITY}) > 0 then 
  buf = buf & Chr(13) & {COMPANIES.CITY} & ", " & {COMPANIES.CITY} & "  " & {COMPANIES.ZIP_CODE}
end if

if (Length({COMPANIES.COUNTRY}) > 0) and ({COMPANIES.COUNTRY} <> "US") then 
  buf = buf & Chr(13) & {COMPANIES.COUNTRY}
end if


formula = buf

Open in new window

0
Comment
Question by:jrollins138
  • 2
5 Comments
 
LVL 12

Expert Comment

by:JayConverse
ID: 35168444
Rule #1, know your data.

Perhaps you need Length(Trim({COMPANIES.ADDRESS3})) > 0
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35168552
I don't see anything wrong with the formula so long as the fields are empty or NULL if they don't have a value.

Since that isn't the formula you are using since it has CITY in twice and missing State.

Can you copy and paste the actual formula?

mlmcc

0
 

Accepted Solution

by:
jrollins138 earned 0 total points
ID: 35168571
Found the answer:

There's an option at the top of the Formula editor dialog that deals with Nulls. I needed to set the choice to "Default Value For Nulls". The default setting was "Exception for Nulls".

What was happening was the blank fields were, in fact, null and the "Exception" was being triggered which caused the formula to return a blank.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35399277
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

777 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