CREATE SUBRECORD

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 11 (Modified)


CREATE SUBRECORD (subtable)

ParameterTypeDescription
subtableSubtableSubtable for which to create a new subrecord

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

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.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next