Connect Data Sources to Master Detail Form Windows

The Master Detail Form Window template consists of a form window with a child table, both of which are connected to a data source. The idea is that the child table displays detail records for the master record. A default connection is straightforward to set up between them using parent keys, but the connection can also be specified manually.

Contents

Master Detail Connection with Parent Keys

To get a default connection between the master and detail records you need to specify the parent key connection between them.

  1. In the form designer, select the form, and in the Properties window connect the master data source.
  2. In the form designer, select the child table, and in the Properties window connect the detail data source.
  3. In order to make the master detail relation work, you need to specify a parent key connection between the master form and the child table. Do this by setting the Key Type property to ParentKey on one or more columns in the child table.

Figure 1: Specifying the parent key connection on a child table column.

This will automatically add a where statement that populates the child table based on the key value of the master according to the column name in the SQL Column property. This requires that the view column names in the SQL Column property on both the field in the master and the column in the child are identical. If for example the master view column is called ORDER_ID while the child view column is called ORDER_NO, the framework will not find a matching parent key. In this case, do a manual master detail connection instead.

Note: The tab order in the form must be setup so that the fields in the master form, which the child table columns refer to, have lower tab index than the child table.

Manual Master Detail Connection

Manual master detail connections can be specified by adding a where statement to the child table's Default 'Where' property. These statements can be combined with parent key connections, and can be as complex as needed to achieve the desired functionality.

ORDER_NO = :i_hWndFrame.frmMyForm.dfsOrderNo

Figure 2: A "where" statement added to the Default 'Where' property on the child table.

This example will produce the same result as the example with parent key connection in the section above. Note that the leading WHERE or AND SQL keywords are omitted in the Default 'Where' property, the framework adds the correct keyword automatically when needed.