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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress field if blank

Status
Not open for further replies.

mmarino

Programmer
Mar 22, 2002
42
US
Hi everyone, this is my problem:
I have an address that comes from 2 separate fields, I use the following formula to display them:
if isnull({tbFlashComment.BusinessAddress1})
then stringvar addr1:=""
else stringvar addr1:={tbFlashComment.BusinessAddress1};
if isnull({tbFlashComment.BusinessAddress2})
then stringvar addr2:=""
else stringvar addr2:={tbFlashComment.BusinessAddress2};
trim(addr1 + " " + addr2) [/color red]
When both fields are blank or null I want to supress the line, so I added the following to my suppress x+2:
if isnull({tbFlashComment.BusinessAddress1})
then stringvar addr1:=""
else stringvar addr1:={tbFlashComment.BusinessAddress1};
if isnull({tbFlashComment.BusinessAddress2})
then stringvar addr2:=""
else stringvar addr2:={tbFlashComment.BusinessAddress2};
if trim(addr1 + addr2)="" then true else false [/color red]

The problem is that the line is still there. Any ideas what I'm doing wrong? or is there an easier way to do this?
Thanks a bunch,

Monica
 
For suppression, you need a 'boolian', a formula that returns true or false. Probably

(isnull({tbFlashComment.BusinessAddress1})
or {tbFlashComment.BusinessAddress1} = " ")
and
(isnull({tbFlashComment.BusinessAddress2})
or tbFlashComment.BusinessAddress2 = " ")

If that doesn't work, copy it as a formula field and display that on the line, to see what you do get.

It is also possible for the suppression formula to test the boolian, e.g. @YourTest = true or just @YourTest

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Thanks Madawc, the field now dissappears but I still have the blank line there. Is there anyway to suppress it and have the rest of the report move up?
Thanks,

mm
 
I use the following to create my address that involved 5 different fields to make up the full address.

Code:
StringVar addr := "";

If isnull({tbFlashComment.BusinessAddress1}) Then
    addr := addr
Else
    addr := {tbFlashComment.BusinessAddress1};

If IsNull({tbFlashComment.BusinessAddress2}) Then
    addr := addr
Else
    addr := addr +" "+{tbFlashComment.BusinessAddress2});

If trim(addr) = "" Then
    ""
Else
    trim(ADDR)

I just modified it for the two fields you requested but should give you a general idea of what the formula does to accomodate additional field if needed.

-LW
 
In your conditional suppression, keep it simple.

Length(Trim({YourAddressFormulaHere})) = 0

will do.

Take the boolean finale out of the end of your original formula, and ensure it finishes with addr1 + addr2 so that your conditional suppression will take both variables into account.

Naith
 
Hi,
Another way to suppress blank lines is to insert a Text Object and place the address formula in that , then set the properties of the Text Object to 'suppress blank lines'.

We use that for Mailing Labels where there can be 4 or 5 lines and it is line 3 that is optional..

[profile]
 
If you are using separate detail sections for each address line, you can add the suppession formula into the formula area for the particular section, and then format the same detail section to "Suppress blank section".

-LB
 
Turkbear,

I did use the text box method but ran into problems with extra spaces when some of the fields were blank.

In my case I print a one line address such as

123 N 31st N #1A Wichita, KS 67202-1234

consists of the following fields

fld1 = 123 (street number)
fld2 = N (street direction)
fld3 = 31st (street name)
fld4 = N (2nd street direction)
fld5 = 1A (Apt, lot, suite #)
fld6 = Wichita (City)
Fld7 = KS (State)
fld8 = 67202 (5-digit ZIP)
fld9 = 1234 (ZIP plus)

With the text box, I get unwanted spaces for null values as well as unwanted # and -, which are optional


-LW

 
Forgot to resolve the last piece of your post.

With my address in a separate detail section, I suppress that section, click x+2 and add the following formula

{@address} = ""

-LW
 
Thanks everyone! I put the different parts of the address in 3 different detail sections and then used the "suppress if blank" option. That did it.
Thanks for all the help :)

mm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top