4D v14.3RELATE MANY |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
RELATE MANY
RELATE MANY
RELATE MANY has two forms. The first form, RELATE MANY(oneTable), establishes all One-to-Many relations for oneTable. It changes the current selection for each table that has a One-to-Many relation to oneTable. The current selections in the Many tables depend on the current value of each related field in the One table. Each time this command is executed, the current selections of the Many tables will be regenerated and the first record of the selection is loaded as the current record.. The second form, RELATE MANY(oneField), establishes the One-to-Many relation for oneField. It changes the current selection and the current record for only those tables that have relations with oneField. This means that the related records become the current selection for the Many table. Note: If the current selection in the One table is empty while the RELATE MANY command is executed, it has no effect. In the following example, three tables are related with automatic relations. Both the [People] table and the [Parts] table have a Many-to-One relation to the [Companies] table. This form for the [Companies] table will display related records from both the [People] and [Parts] tables. When the People and Parts forms are displayed, the related records for both the [People] table and the [Parts] table are loaded and become the current selections in those tables. On the other hand, the related records are not loaded if a record for the [Companies] table is selected programmatically. In this case, you must use the RELATE MANY command. Notes:
For example, the following method moves through each record of the [Companies] table. An alert box is displayed for each company. The alert box shows the number of people in the company (the number of related [People] records), and the number of parts they supply (the number of related [Parts] records). In the example, the argument to the ALERT command is printed on multiple lines for clarity. Note that the RELATE MANY command is needed, even though the relations are automatic. ALL RECORDS([Companies]) ` Select all records in the table |
PROPERTIES
Product: 4D
HISTORY
Created: < 4D v6 SEE ALSO ARTICLE USAGE
4D Language Reference ( 4D v12.4) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||