Microsoft KB Archive/87851

{| = How to Remove Blank Lines in FoxPro Labels and Reports =
 * width="100%"|

ID: Q87851

The information in this article applies to:


 * Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a

SUMMARY
Blank lines can appear in your labels and reports if an expression in the definition evaluates to null. Below is an example that demonstrates how to remove these blank lines.

MORE INFORMATION
A common example is the presence in a database of two address fields, ADDRESS1 and ADDRESS2, where ADDRESS2 is sometimes empty.

Sample label definition:

COMPANY ADDRESS1 ADDRESS2; TRIM(CITY) + &quot;, &quot; + STATE + &quot; &quot; + LTRIM(ZIP) To prevent blank lines from printing in your labels if certain customers don't have ADDRESS2 fields, place a semicolon after ADDRESS2 in the label definition. If ADDRESS2 (or any other expression followed by a semicolon) evaluates to null, that line is removed from the label and the remaining lines are moved up. NOTE: Placing a comma between fields in a label expression automatically trims the preceding field and places a single space between it and the following field.

Removing Blank Lines and Empty Fields in Reports
Blank lines can appear in your reports if an expression in the definition evaluates to null.

A common example is the presence in a database of two address fields, ADDRESS1 and ADDRESS2, where ADDRESS1 always contains data and ADDRESS2 is sometimes empty.

Sample report definition to remove blanks if ADDRESS2 is empty (detail bands):

Detail | COMPANY Detail | ADDRESS1 + &quot;;&quot; + ALLTRIM(ADDRESS2) Detail | TRIM(CITY) + &quot;, &quot; + STATE + &quot; &quot; + LTRIM(ZIP) Detail | MDY(DATE) Detail | To prevent blank lines from printing in your report if certain customers don't have ADDRESS2 fields: 1. Create the following expression:

ADDRESS1 + &quot;;&quot; + ALLTRIM(ADDRESS2)

a. Type &quot;@;&quot; (without the quotation marks) in the Format box in the Report Expression dialog box to interpret the semicolon and force a linefeed between ADDRESS1 and ADDRESS2.

b. Use the ALLTRIM function on ADDRESS2 to prevent blanks from appearing if ADDRESS2 contains only spaces. 2. If you want any expressions on following lines (for example, CITY  and DATE) to move up if ADDRESS2 is null, select the Float As Band Stretches check box in the Report Expression dialog box for these expressions. If ADDRESS2 evaluates to null, that line is removed from the report and the following lines are moved up.

NOTE: If you want the full year to display for the MDY(DATE) expression, be sure to use SET CENTURY ON.

Occasionally, you may have a situation where ADDRESS1 or ADDRESS2 may be empty. In a case like this, you must set up your report definition as follows. Listed below is a sample report definition to remove blanks if ADDRESS1 or ADDRESS2 is empty (detail bands):

Detail | COMPANY + ALLTRIM(ADDRESS1) + &quot;;&quot; + ALLTRIM(ADDRESS2) Detail | TRIM(CITY) + &quot;, &quot; + STATE + &quot; &quot; + LTRIM(ZIP) Detail | MDY(DATE) Detail | To prevent a blank line from printing in your report if certain customers don't have an ADDRESS1 or an ADDRESS2 field: 1. Create an expression like the following:

COMPANY + ALLTRIM(ADDRESS1) + &quot;;&quot; + ALLTRIM(ADDRESS2).

a. In the Width box of the Report Expression dialog box, type the width of the COMPANY field. This is used instead of a semicolon for the following reasons: If there IS an ADDRESS1 field, it     appears on the next line because you allowed room only for COMPANY on the first line. If there is NOT an ADDRESS1 field, no     blank line appears because you did not force a linefeed with the semicolon.

NOTE: The ALLTRIM function is used on each address to     prevent blanks when the address fields contain only spaces.

b. Type &quot;@;&quot; (without the quotation marks) in the Format box in the Report Expression dialog box to interpret the semicolon and force a linefeed between ADDRESS1 and ADDRESS2. 2. If you want any expressions on following lines (for example, CITY  and DATE) to move up if ADDRESS2 is null, select the Float As Band Stretches check box in the Report Expression dialog box for these expressions. If ADDRESS2 evaluates to null, that line is removed from the report and the following lines are moved up.

NOTE: If you want the full year to display for the MDY(DATE) expression, be sure to use SET CENTURY ON. Additional reference words: FoxDos 2.00 2.50 2.50a suppress KBCategory: kbprint kbprg KBSubcategory:
 * }