4D v13.4

CREATE SUBRECORD

Home

 
4D v13.4
CREATE SUBRECORD

CREATE SUBRECORD 


 

CREATE SUBRECORD ( subtable ) 
Parameter Type   Description
subtable  Subtable in Subtable for which to create a new subrecord

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.

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)

 
PROPERTIES 

Product: 4D
Theme: Subrecords
Number: 72

This command is deprecated and should not be used anymore

 
INDEX

Alphabetical list of commands

 
HISTORY 

Modified: 4D v11 SQL

 
SEE ALSO 

ADD SUBRECORD
DELETE SUBRECORD
MODIFY SUBRECORD
SAVE RECORD