Solved

Suppressing blank lines in an address block

Posted on 2011-03-18
5
454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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