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. Open the accounts.4fdm file and select the Form tab.
  2. Enlarge the grid by dragging its middle circle downwards.
    Figure: Expand grid in form

    This figure shows the accounts.4fdm form with the grid being expanded vertically.
  3. Select Container > Data Control.
    The Extend Form from Database dialog displays, showing the Column Selection page.
  4. Add fields from the Orders table:
    1. Select the officestore database and the orders table.
    2. Select these fields: orderid, userid, orderdate, totalprice, and creditcard.
    3. Use the single right arrow to add these fields to the Selected Fields list.
    4. Click Next.
  5. Select Table as the container, and click Finish.
    The cursor is set to allow you to place your container on the form.
  6. Draw the container within the enlarged grid, under the existing fields.
    This form design now contains fields from both the accounts and orders tables.
    Figure: Form tab

    This figure is a screenshot of the accounts.4fdm form containing fields from the account table and orders table.
  7. Select the Records tab.
  8. Select record1. In the Properties view, change name to account_record. Ensure the active property is checked and the unique key is account.userid.
    Tip:

    The unique key is identified by the key icon.

    Figure: Account table record

    This figure is a screenshot of the account record.
  9. Select record2. Change its name to order_record. Ensure the active property is checked and the unique key is orders.orderid.
    Figure: Order table record

    This figure is a screenshot of the order record.
  10. Set the relationship between the account and order records. Right-click the orders.userid field in the order_record table record, and select Add Relation To. Drag the arrow to point to the account.userid in the account_record.
    Figure: Master-detail relationship

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

    account_record is now the Master record, and order_record is the detail record.

  11. Select File > Save All to save the project and the modifications to its contents.
  12. In appflow.4ba, right-click the Main program entity and select Build Program.
  13. Right-click the Main program entity and select Execute Program.
    Figure: The application executes

    This figure is a screenshot of the application running, showing the master-detail data.
  14. Navigate around the database using the top menu icons. When you are finished, select File > Exit.