The information in this article applies to:
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
- Microsoft FoxPro for Windows, versions 2.5 and 2.5a
SYMPTOMS
Variables defined in the Report Writer appear to be calculated
incorrectly.
CAUSE
The variable that appears to be calculated incorrectly is making
reference to another, as yet undefined, variable. This is because
variables are defined and calculated in the order they are listed in
the variable list.
RESOLUTION
In the variable list, change the order of the variables so that if a
variable (mvarA) makes reference to another variable (mvarB) in the
Value To Store box, the referenced variable (mvarB) appears earlier in
the variable list. See below for a detailed explanation of the problem
and its resolution.
MORE INFORMATION
Steps to Reproduce Problem
- In the Command window, type the following:
USE \FOXPRO2\TUTORIAL\CUSTOMER.DBF
(The directory specified will depend on the version of FoxPro and
where it is stored on the system.)
- In the Command window, type:
CREATE REPORT VARTEST.FRX
- Create three variables as follows:
a. From the Report menu, choose Variables.
b. Choose the Add button.
c. In the Variable Name box, type "maverage" (without the quotation
marks).
d. In the Value To Store box, type "msum/mcount" (without the
quotation marks).
e. Choose the OK button.
f. Choose the Add button.
g. In the Variable Name box, type "msum" (without the quotation
marks).
h. In the Value To Store box, type "customer.ytdpurch" (without the
quotation marks).
i. Under Calculate, select the Sum option button.
j. Choose the OK button.
k. Choose the Add button.
l. In the Variable Name box, type "mcount" (without the quotation
marks).
m. In the Value To Store box, type "customer.ytdpurch" (without the
quotation marks).
n. Under Calculate, select the Count option button.
o. Choose the OK button.
p. In the Report Variables dialog box, choose the OK button.
- Move to a Detail line and add the following fields:
- customer.ytdpurch (from database field list)
- msum (from variable list)
- mcount (from variable list)
- maverage (from variable list)
- From the Report menu, choose Page Preview.
Note that the first "Average" is ******** (it should be equal to
the sum). Also note that the second average uses the sum and count
from the first record instead of the second record.
To correct the problem in this case:
- From the Report menu, choose Variables.
- In the Variables list, highlight maverage.
- Drag maverage to the end of the list (or hold down the CTRL key
while pressing the DOWN ARROW key).
- Choose the OK button.
- From the Report menu, choose Page Preview.
|