Removing data lines

I have a crystal report
With some fields that do not contain data
I would like to suppress these and move other data up in it's place
Address 1
Address 2

so I may not have any data for address2 so rather than a gap, can I then see, with no gap

Gordon HughesDirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
You can create a formula field like this (basic syntax):

dim strAddress as String

strAddress =""

if not isnull({Headers.Line1}) and len({Headers.Line1}) > 0 then
    strAddress = strAddress & {Headers.Line1} & chr(10) & chr(13)
end if

if not isnull({Headers.Line2}) and len({Headers.Line2}) > 0 then
    strAddress = strAddress & {Headers.Line2} & chr(10) & chr(13)
end if

if not isnull({Headers.City}) and len({Headers.City}) > 0 then
    strAddress = strAddress & {Headers.City} & ", "
end if

Formula = strAddress

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gordon HughesDirectorAuthor Commented:
Hi Eric
Do I create a new formula for this and if so where do I put it?
Éric MoreauSenior .Net ConsultantCommented:
yes you need to create a new formula. check
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Raghavendra HullurSoftware DeveloperCommented:
An alternative way would be to display the individual fields in separate sections and suppress the sections if the particular database field displayed in that section is blank.

Something like this:

Say you are displaying the Address 1, Address 2, Town etc.. in a single section for ex. detail section.
Then, you can create as many new detail sections as the number of fields you need to display and include those individual fields like

Address 1: {Addres1 datbase field} etc.

and you can write a suppress condition at section expert for that particular section using a suppress condition like
isNull({Addres1 datbase field})

The highlighted field needs to be replaced with your database field.

Repeat this for each of the fields you need to display.
Gordon HughesDirectorAuthor Commented:
Thanks for your support
FWIW, if you put the fields in separate sections (with nothing else in the section), then you should be able to just use the "Suppress blank section" option in the Section Expert to suppress those sections, rather than creating a suppression formula.  Either one works.  "Suppress blank section" is just a bit easier.

Gordon HughesDirectorAuthor Commented:
Hi James
That is what I am doing
Raghavendra HullurSoftware DeveloperCommented:
Well, if there is nothing else in that section, then what James suggested would definitely work.
But, in case, you want to display a label for each of those fields, then the section won't be blank.
That's why I suggested to use section expert level suppression.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.