Add a detail list to the form

Add a list to your form and create the master-detail relationship.

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 fields from the master table to make room for the fields from the other table.
  2. Select Container > Data Control.
    The Extend Form from Database dialog displays, showing the Column Selection page.
  3. Select these columns from the orders table: orderid, userid, orderdate, totalprice and creditcard. Click Next >.
  4. Select Table as the container. and click Finish.
    The cursor is set to allow you to place your container on the form.
  5. Draw the container within the enlarged grid, under the existing fields.
    This form design now contains fields from the master table (account) and a detail table (orders).

    Figure: Form tab


    This figure is a screen shot of the form tab showing the form containing fields from the master table and detail table.
  6. 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.
    Tip: The unique key is identified by the key icon.

    Figure: Master table record


    This figure is a screenshot of the master table record.
  7. Do the same for the detail table record.

    Figure: Detail table record


    This figure is a screenshot of the detail table record.
  8. 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).

    Figure: Master-detail relationship


    This figure is a screenshot showing the relationship between the master and detail record.
  9. Select File > Save All to save the project and the modifications to its contents.
  10. Build and execute the program.

    Figure: The application executes


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