version 11 (Modified)
ADD SUBRECORD (subtable; form{; *})
Parameter | Type | Description | |
subtable | Subtable | Subtable to use for data entry | |
form | String | Form to use for data entry | |
* | Hide scroll bars |
Compatibility note: Subtables are no longer supported starting with version 11 of 4D. A compatibility mechanism ensures the functioning of this command in converted databases; however, it is strongly recommended to replace any subtables with standard related tables.
Description
The ADD SUBRECORD command lets the user add a new subrecord to subtable, using the form form. ADD SUBRECORD creates a new subrecord in memory, makes it the current subrecord, and displays form. A current record for the parent table must exist. If a current parent record does not exist for the process, ADD SUBRECORD has no effect. The form must belong to subtable.
The subrecord is kept in memory (accepted) if the user clicks an Accept button or presses the Enter key (numeric pad), or if the ACCEPT command is executed. After the subrecord has been added, the parent record must be explicitly saved in order for the subrecord to be saved.
The subrecord is not saved if the user clicks a Cancel button or presses the cancel key combination (Ctrl-Period on Windows, Command-Period on Macintosh), or if the CANCEL command is executed.
After a call to ADD SUBRECORD, OK is set to 1 if the subrecord is accepted, to 0 if canceled.
The form is displayed in the frontmost window of the process. The window has scroll bars and a size box. Specifying the optional * parameter causes the window to be drawn without scroll bars or a size box.
Example
The following example is part of a method. It adds a subrecord for a new child to an employee's record. The data for the children is stored in a subtable named [Employees]Children. Note that the [Employees] record must be saved in order for the new subrecord to be saved:
ADD SUBRECORD([Employees]Children;"Add Child") If (OK=1) ` If the user accepted the subrecord SAVE RECORD ([Employees]) ` save the employee's record End if
See Also
ACCEPT, CANCEL, CREATE SUBRECORD, DELETE SUBRECORD, MODIFY SUBRECORD, SAVE RECORD.
System Variables or Sets
Accepting the subrecord sets the OK system variable to 1; canceling it sets the OK system variable to 0.