Add a detail list to the form

A Genero application can display a form that contains a master-detail relationship between two tables. The user can search for a row in the master table, and the corresponding rows in the detail table will also be displayed. The values in rows from both tables can be added, deleted, or modified.

The form must contain fields from both tables and the table relationships must be set.

  1. In the form, enlarge the grid around the master table to make room for the fields from the other table.
  2. Select Container >> Data Control and select these columns from the orders table: orderid, userid, orderdate, totalprice and creditcard. The container for these fields can be a table (to display multiple rows). Click Next, select a Table container, click Finish and draw the container within the enlarged grid, under the original.

    This form design now contains fields from the master table, account, and a detail table, orders.


    This figure is a screenshot of the form tab showing the form containing fields from the master table and detail table.

    Figure 1. Form tab

  3. Select the Records tab. Select the master table record and make sure the active property is checked. Select and identify a column as the unique key, if not already identified, as indicated with the key icon.

    This figure is a screenshot of the master table record.

    Figure 2. Master table record

  4. Do the same for the detail table record.

    This figure is a screenshot of the detail table record.

    Figure 3. Detail table record

  5. Set the relationship between the master and detail records. Right-click the foreign key field in the detail table record (orders.userid, in our example), and select Add Relation To. Drag the arrow to point to the primary key in the master table record (account.userid).

    This figure is a screenshot showing the relationship between the master and detail record.

    Figure 4. Master-detail relationship

  6. Select File>>Save All to save the project and the modifications to its contents.
  7. Build and execute the program.

    This figure is a screenshot of the application running, showing the master-detail data.

    Figure 5. The application executes