Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppressing Blank Lines without dividing the Details section?

Status
Not open for further replies.

CarolineS

Programmer
Aug 31, 2001
33
CA
Hi,

I've created an invoice, and would like to suppress lines of the address (Business Title, Address Line @ etc.) if they are null, so that there are no blank lines.

However: I can't divide the address and make each line into a separate Detail section, because one address set has a box around it, and the other address set has invoice info (price, tax) on the same line which needs to appear every time. So that method of suppressing is out.

I read in another post here about embedding each field into a text box and then checking "Suppress Embedded Field Blank Lines". That didn't work either.

Any tips about how to suppress field by field so that upon printing, there will be no blank lines in the body of some of the addresses?

Thanks.
 
It is tedious, but it can be done.

Let us assume that you have up to five address lines:
line 1: Contact Name
line 2: Company Name
Line 3: Street address #1
Line 4: Street address #2
Line 5: City, state, zip

Let us also assume that each record must have either
contact name or company name or both. Also it must have street address #1, but #2 may be blank. Every record must have city, state, zip.

So: Formula @line1:
shared numbervar L1 := if isnull({table.contact})then 1 else 0;
shared numbervar L2 := if isnull({table.company}) then 1 else 0;
shared numbervar S1 := L1 + L2;
if s1 =2 then {table.contact} else if L1 =1 then {table.contact} else {table.company}

Formula @line2:
Shared numbervar L1;
Shared numbervar L2;
Shared numbervar S1;
if S1 =2 then {table.company} else {table.Address1}

and so on....

We go over this in detail in our level 2 book.

Howard Hammerman On-site/Phone Crystal Reports Training/Consulting and books

 

Luckily, it's only the Address 2 line I have to worry about, so I'll only have to use your suggested formula on two lines.

Further up, I fixed the contact name + possible title issue by checking if there was a title, and if so adding a comma and the title onto to the same line, so that blanks in the Title field wouldn't matter.

Thanks Howard.
 
Hi Caroline;

this looks complicated but it works really fast...I had to do this for a report where literally all possible fields used could be NULL so you had to test each field

************ Start of @customerInfo formula **********

WhilePrintingRecords;
stringVar custInfo := "";

// customer name
if not isnull({Tablename.CNAME}) and length(Trim({Tablename.CNAME})) > 0 then
custInfo := custInfo + Trim({Tablename.CNAME}) + chr(13) + chr(10);

// customer address1
if not isnull({Tablename.CAD1}) and length(Trim({Tablename.CAD1})) > 0 then
custInfo := custInfo + Trim({Tablename.CAD1}) + chr(13) + chr(10);

// customer address2
if not isnull({Tablename.CAD2}) and length(Trim({Tablename.CAD2})) > 0 then
custInfo := custInfo + Trim({Tablename.CAD2}) + chr(13) + chr(10);

// customer city
if not isnull({Tablename.CITY}) and length(Trim({Tablename.CITY})) > 0 then
custInfo := custInfo + Trim({Tablename.CITY}) + space(3);

// customer prov/state abbreviation
if not isnull({Tablename.CSTE}) and length(Trim({Tablename.CSTE})) > 0 then
if not isnull({Tablename.CITY}) and length(Trim({Tablename.CITY})) > 0 then
custInfo := custInfo + Trim({Tablename.CSTE}) + chr(13) + chr(10)
else
custInfo := custInfo + Trim({Tablename.CSTE}) + chr(13) + chr(10);

// customer Country
if not isnull({Tablename.CCOUN}) and length(Trim({Tablename.CCOUN})) > 0 then
if not isnull({Tablename.CSTE}) and length(Trim({Tablename.CSTE})) > 0 then
custInfo := custInfo + Trim({Tablename.CCOUN}) + space(3)
else if not isnull({Tablename.CITY}) and length(Trim({Tablename.CITY})) > 0 then
custInfo := custInfo + chr(13) + chr(10) + Trim({Tablename.CCOUN}) + space(3)
else
custInfo := custInfo + Trim({Tablename.CCOUN}) + space(3);

// customer Postal/zip
if not isnull({Tablename.CZIP}) and length(Trim({Tablename.CZIP})) > 0 then
if not isnull({Tablename.CCOUN}) and length(Trim({Tablename.CCOUN})) > 0 then
custInfo := custInfo + Trim({Tablename.CZIP})
else
custInfo := custInfo + Trim({Tablename.CZIP});

custInfo;

************ end of @customerInfo formula **********

When you place this on your report make the field "Can Grow" and leave enough space under it so that it doesn't overwrite something....I usually put it in a separate section myself to absolutely prevent that...but sometimes that cannot be done as you pointed out.

You may not need all of this but the framework is there for you to modify

Hope this helps you

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top