PRB: Can't Print GrandChild Records in One-to-Many Relation

Last reviewed: September 25, 1997
Article ID: Q136674
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a
  • Visual FoxPro for Macintosh, version 3.0b

SYMPTOMS

A report for three tables, where the tables have a parent, child, and grandchild one-to-many relation, does not display all the related records in the grandchild table for each of the records in the child table. Only the first related grandchild record prints.

RESOLUTION

To list all the related records in the grandchild table for each of the records in the child table:

  • Use the SET SKIP command. Place it in the Init event of the report's data environment to set the one-to-many relation from child and grandchild into the parent.

    -or-

  • Set the IntitialSelectedAlias property of the report's data environment to the child table.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open the Testdata Database that should be in the \Samples\Data directory under the Main Visual FoxPro directory.

  2. Create a new report, and call it Test.

  3. Open the data environment of the report and add the Customer, Orders, and OrdItems tables to it. Make sure the relation is set among these tables so that the Orders table is a child of the Customer table, and the OrdItems table is a child of the Orders table. The OrdItems table is the grandchild of Customer table.

  4. Set the OneToMany property of both the relations in the report data environment to true (.T.-True).

  5. Set the Order property of the Customer table to Cust_Id and the Order property of the Orders table to Order_Id.

  6. Set the InitialSelectedAlias property of the report data environment to the Customer table.

  7. Create a report group for Customer.Cust_Id and another report group for Orders.Order_Id.

  8. Place the Cust_Id and Company fields of the Customer table in the first group header (Customer.Cust_Id).

  9. Place the Order_Id and Order_Amt fields of the Orders table in the second group header (Orders.Order_Id).

  10. Place the Line_No,Product_ID, and Unit_Price fields of the OrdItems

        table in the Detail band.
    

  11. Add whatever titles you think are necessary to each of the Bands.

  12. Preview the Report. Only one OrdItems record related to each of the

        Orders record appears.
    

Example Resolution

To fix this behavior:

  • Add the following code to the Init event of the report data environment:

    SELECT Customer SET SKIP TO Orders,OrdItems

    -or-

  • Set the InitialSelectedAlias of the report data environment to Orders.

Keywords          : FxtoolRwriter VFoxMac vfoxwin
Version           : Win:3.0,3.0a,5.0,5.0a; Mac:3.0
Issue type        : kbprb


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 25, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.