Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual FoxPro
Expertise: Beginner
Sep 22, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Report Contains Too Many Fields to Fit on a Sheet

I am outputting a report that contains more fields than will fit on a single sheet. The process has to be done as three separate reports:
  • Report 1 - Fields 2 to 14
  • Report 2 - Fields 15 to 27
  • Report 3 - Fields 28 to 40
How can I put variables into the report fields to point to the relevant table fields? This would enable me to use one report and vary the field reference. I hope this makes sense.

This can be accomplished using the EVAL() and FIELD() functions in combination with a memory variable that holds the field number of the first column in the report. Here is a simple example that will demonstrate the solution.

Let's say that you have a table with seven fields in it (f1, f2..., f7). Let's also say that the report that you create can only show three columns.

First create a report, add the table to the data environment of the report, and then put three fields onto the report designer surface. Fill in the expressions and the "Print When"s as follows:

Field      Expression                    Print When
-----      ----------                    -----------
First      EVAL(FIELD(lnStartField))     !EMPTY(FIELD(lnStartField))
Second     EVAL(FIELD(lnStartField+1))   !EMPTY(FIELD(lnStartField+1))
Third      EVAL(FIELD(lnStartField+2))   !EMPTY(FIELD(lnStartField+2))

lnStartField = 1
REPORT FORM MyREPORT && shows fields 1-3
lnStartField = 4
REPORT FORM MyREPORT && shows fields 4-6
lnStartField = 7
REPORT FORM MyREPORT && shows only field 7
You can use the same technique to make sure that the column headers in the report give the correct field name above its value. Create three fields (not labels) in the page header of the report, corresponding to (and right above) the three fields you first added. Set their expressions and "Print When"s as follows:
Field      Expression              Print When
-----      ----------              -----------
First      FIELD(lnStartField)     !EMPTY(FIELD(lnStartField))
Second     FIELD(lnStartField+1)   !EMPTY(FIELD(lnStartField+1))
Third      FIELD(lnStartField+2)   !EMPTY(FIELD(lnStartField+2))
Notice that the EVAL() function is not used because we want the name of the field, not the contents of the field.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date