PRB: Query to a Report Causes an Inaccurate Sum or CountID: Q120187 2.00 2.5x 2.60 2.60a | 2.5x 2.60 2.60a 3.00| 2.5x 2.60a | 2.60
The information in this article applies to:
- Microsoft Visual FoxPro for Windows, version 3.0 - Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6, 2.6a - Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a - Microsoft FoxPro for Macintosh, versions 2.5x, 2.6 - Microsoft FoxPro for UNIX, version 2.6
SYMPTOMSWhen you are running a query to a report using two or more databases with a one-to-many relationship and the report is counting or performing other math functions on fields from the parent database, the count or value from the math functions is inaccurate.
RESOLUTIONTo get an accurate count, you need to create a user-defined function (UDF). For an example of a UDF that produces the correct count, see "Workaround" in the "More Information" section below.
MORE INFORMATIONWhen the report performs a count or any math function, it looks to the source database for its information. If the data comes from a query, the source is a temporary table called QUERY. If the query had two or more tables in it with a one-to-many relationship, there will be a matching parent field for each child field.
Steps to Reproduce Problem1. Use the CUSTOMER.DBF and INVOICES.DBF tables that are found in the 2. Create a report that contains the CUSTOMER.CNO, CUSTOMER.STATE,
3. Group the report by state.
4. In the group footer band, place the CNO field and select Calculate and 5. Save the report.
6. Open a query and add the CUSTOMER and INVOICES tables. 7. Add the fields listed above to the fields list in the query. 8. Order the query by state. 9. Output the query to the report saved in step 5 above. If you look at the group from the state of "GA", you will see that the count is 7 but that there are only four different companies.
WorkaroundTo obtain the correct count, you can use the following UDF.
REFERENCESFoxPro for Windows "Getting Started," Chapter 9 FoxPro for Windows and MS-DOS "Language Reference," page L3-1114 Additional reference words: VFoxWin 3.00 FoxUnix FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.50c 2.60 2.60a KBCategory: kbprb KBSubcategory: FxprgGeneral
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |