version 3
CREATE SUBRECORD (subtable)
Parameter | Type | Description | |
subtable | Subtable | Subtable for which to create a new subrecord |
Description
CREATE SUBRECORD creates a new subrecord for subtable and makes the new subrecord the current subrecord. The new subrecord is saved only when the parent record is saved. The parent record can be saved by a command such as SAVE RECORD or by the user accepting the record. If there is no current record, CREATE SUBRECORD has no effect. To add a new subrecord through a subrecord input form, use ADD SUBRECORD.
Example
The following example is an object method for a button. When it is executed (that is, when the button is clicked), it creates new subrecords for children in the [People] table. The Repeat loop lets the user add children until the Cancel button is clicked. The form displays the children in an subform, but will not allow direct data entry into the subtable because the Enterable option has been turned off:
Repeat ` Get the child's name vChild := Request("Name (cancel when done):") ` If the user clicked OK If (OK = 1) ` Add a new subrecord for a child CREATE SUBRECORD([People]Children) ` Assign child's name to the subfield [People]Children'Name:=vChild End if Until (OK=0)
See Also
ADD SUBRECORD, DELETE SUBRECORD, MODIFY SUBRECORD, SAVE RECORD.