Microsoft KB Archive/138438

= How To Display Child Records Based on a Parent Record =

Article ID: 138438

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q138438



SUMMARY
You can display child records based on the selection of a specific parent record by using two forms with both a parameter and a custom property in the child form. This article shows you how to do it.



MORE INFORMATION
The following steps create two forms namded Parent and Child and use the Customer and Orders tables from the Tastrade database.

Create the Parent Form
  Open the Tastrade database by typing the following in the Command window: OPEN DATA C:\VFP\SAMPLES\MAINSAMP\DATA\TASTRADE In Visual FoxPro 6.0, type the following: OPEN DATA HOME(2)+"TASTRADE\DATA\TASTRADE"  Create a new form called Parent. In the data environment for the Parent form, add the Customer table from Tastrade. Drag the Customer table from the data environment to the form to create a grid. Click the grid. Right-click the grid, and then click Properties. Set the ColumnCount property to 15.  Place the following code in the Header1 DblClick event: DO FORM child WITH customer.customer_id </li> Close and save the Parent form.</li></ol>

Create the Child Form
<ol> Create a new form called Child.</li> Add the Orders table to the data environment of the Child form.</li> On the Form menu, click New Property. Type in the new property name of Parent_Key.</li> Drag Order_Id, Customer_Id, Order_Number, and Order_Date fields individually from the data environment to the form to create text boxes for each field.</li>  In the Child form's Init event, enter this code: PARAMETER PARENT_KEY SELECT ORDERS SET FILTER TO customer.customer_id = orders.customer_id GO TOP </li> Save the Child form.</li>  Type the following in the Command window: DO FORM PARENT. </li></ol>

When the record pointer in the Customer table moves to a Customer_Id of BLAUS, for example, double-click the header for the Customer_Id field (called Header1). The Child form brings up information for order #103 dated 10/28/92.

Keywords: kbhowto kbdesigner KB138438

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.