The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
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:
- 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.
- Enter the following command line in the Command window:
MODIFY REPORT column.frx
- 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.
- 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.
- 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.
- 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.
- 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.
- Minimize COLUMN.FRX, and enter the following line of code in the Command
window:
MODIFY COMMAND coltrac.prg
- Insert the following code in the COLTRAC.PRG file:
nulstrng = ""
numocols = 3
IF (colnum/numocols)=1
colnum=0
ENDIF
RETURN nulstrng
- 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).
- 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).
- 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).
- 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.
- 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.
|