Removing data lines

Gordon Hughes
Gordon Hughes used Ask the Experts™
on
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
Ie
Address 1
Address 2
Town

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

Gordon
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior .Net Consultant
Top Expert 2016
Commented:
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

Gordon HughesDirector

Author

Commented:
Hi Eric
Do I create a new formula for this and if so where do I put it?
Gordon
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
yes you need to create a new formula. check https://kb.blackbaud.com/articles/Article/41726
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Commented:
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 HughesDirector

Author

Commented:
All
Thanks for your support
Gordon
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.

 James
Gordon HughesDirector

Author

Commented:
Hi James
That is what I am doing
Thanks
Gordon

Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial