How to Print Headings Vertically Down Left Edge of .FRX

ID: Q124422

The information in this article applies to:

SUMMARY

This article shows by example how to create a vertical columnar report in FoxPro that assigns a heading to each line of the report and prints the headings vertically down the left edge of the report rather than printing them horizontally across the top.

MORE INFORMATION

You can't print the headings down the left edge by using the Print When dialog of Report Writer because the 'Print Once Per Band' and 'Also Print' options do not sufficiently control the row headings in the Detail band; these options don't allow you to print the headings more than once per page.

Step-by-Step Example

Work around this behavior and print vertical headings by following these steps:

1. From the Command window, enter the following command lines:

   SET DEFAULT TO C:\FPW26\TUTORIAL
   USE customer

   NOTE: Replace the drive letter and FoxPro directory name with the actual
   names from your computer.

2. Enter the following command line in the Command window:

   MODIFY REPORT column.frx

3. Maximize the COLUMN.FRX report when it appears. Grab the Detail band
   button, and drag the Detail band down to about the three-inch mark.

4. Click Report on the menu bar, and select the Quick Report option. From
   the Quick Report dialog, choose the vertical Field Layout button, and
   click OK.

5. Click Report again. Then click the Page Layout option. Increment the
   column spinner to 3, and set the Print Order so that the report's output
   will print across the page (that is, select the right button of the two
   buttons under Print Order:). Then click OK.

6. From the toolbox on the left edge of the report, choose the Field
   button. Then click the cursor directly under the last field created in
   the Detail band. If there is not enough room under the last field in the
   Detail band, open up more detail area by dragging the Detail band button
   further down the page.

7. When the Report Expression dialog box appears, type coltrac() as the
   user-defined function (UDF) name in the text box located to the right
   of the Expression button. Then choose the OK button.

8. Minimize COLUMN.FRX, and enter the following line of code in the Command
   window:

   MODIFY COMMAND coltrac.prg

9. Insert the following code in the COLTRAC.PRG file:

   nulstrng = ""
   numocols = 3

   IF (colnum/numocols)=1
      colnum=0
   ENDIF

   RETURN nulstrng

10. Save the file and minimize COLTRAC.PRG

    NOTE: numocols should be assigned a value equal to the number of
    columns set up in the .FRX file's Page Layout. If the number of columns
    in the .FRX file ever changes, you'll need to also change the value
    assigned to numocols in this program (COLTRAC.PRG).

11. Go back to the COLUMN.FRX report. Click Report from the menu bar and
    choose the Variables... option. Then select the Add button. Type the
    variable name as "colnum" (without the quotation marks).

12. In the text box under the Value to Store... button, type the variable
    name (colnum). Now the value in the box under the Initial Value...
    button should be 0 (zero).

13. Select the Count radio button, and click two OK buttons to get back to
    the report. Process these steps:

    a. Double-click a row heading (for example, cno) within the Detail
       band. When the text dialog box appears, select the Print When
       check box.

    b. From the Print When dialog box, select the Print Only When
       Expression is True check box.

    c. When the Expression Builder dialog appears, double-click colnum from
       the variables list, and when colnum appears in the Print Text When
       expression box, assign a value of 1 to colnum (that is, colnum=1).
       Then click OK three times to return to the report.

14. Repeat step 13 for each row heading in the Detail band. Then select
    Report from the menu bar, and choose Page Preview to view the result of
    this process.

Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 2.60a KBCategory: kbprg kbprint kbcode KBSubcategory: FxprgGeneral

Last Reviewed: June 27, 1995