Reportpax Labels Questions

ID #1007

How do I eliminate blank lines when printing labels?


Here is a quick tip on eliminating blank lines when printing labels. To give you an example of this, let's say you are printing an Address Line 1 and an Address Line 2 on your labels. However some records do not have an Address Line 2 and you do not want to have the blank line printed for those labels (similar to the picture below where the first record does not have a company so a blank line is printed):


To fix this, you just need to add some custom code to fit your needs:

1) Bring up the report in VS and click Report -> Report Properties menu item

2) Click the Code tab and paste this code at the bottom:
function FieldThenNewLine(field)
    if field = "" then
        return ""
    else
        return field & chr(13) & chr(10)
    end if
end function


3) Now you must edit the Label expression to something like this:
=
Code.FieldThenNewLine(Fields!ContactName.Value) &
Code.FieldThenNewLine(Fields!CompanyName.Value) &
Code.FieldThenNewLine(Fields!Address.Value) &
Code.FieldThenNewLine(Fields!City.Value  & ", " & Fields!Region.Value  & "  " & Fields!PostalCode.Value) &
Code.FieldThenNewLine(Fields!Phone.Value)

Now a new line will only print if the field is not blank.

Last update: 2007-12-11 15:41
Author: ReportPax Support
Revision: 1.1

Print this record Print this record
Send to a friend Send to a friend
Show this as PDF file Show this as PDF file
Export as XML-File Export as XML-File

Please rate this entry:

Average rating: 0 out of 5 (0 Votes )

completely useless 1 2 3 4 5 most valuable

You can comment on this entry