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.
To get a default connection between the master and detail records you need to specify the parent key connection between them.
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 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.