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.
-
In the form, enlarge the grid around the master table to make room for the fields from the
other table.
-
Select .
The Extend Form from Database dialog displays, showing the
Column Selection page.
-
Select these columns from the orders table: orderid, userid, orderdate, totalprice and
creditcard. Click Next >.
-
Select Table as the container. and click Finish.
The cursor is set to allow you to place your container on the form.
-
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 1. Form tab
-
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.
Figure 2. Master table record
- Do the same for the detail table record.
Figure 3. Detail table record
-
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 4. Master-detail relationship
-
Select to save the project and the modifications to its contents.
-
Build and execute the program.
Figure 5. The application executes