4D v13.4

CREATE RECORD

Home

 
4D v13.4
CREATE RECORD

CREATE RECORD 


 

CREATE RECORD {( aTable )} 
Parameter Type   Description
aTable  Table in Table for which to create a new record, or Default table, if omitted

CREATE RECORD creates a new empty record for table, but does not display the new record. Use ADD RECORD to create a new record and display it for data entry.

CREATE RECORD is used instead of ADD RECORD when data for the record is assigned with the language. The new record becomes the current record but the current selection is left untouched.

The record exists in memory only until a SAVE RECORD command is executed for the table. If the current record is changed (for example, by a query) before the record is saved, the new record is lost.

Example  

The following example archives records that are over 30 days old. It does does this by creating new records in an archival table. When the archiving is finished, the records that were archived are deleted from the [Accounts] table:

  ` Find records more than 30 days old
 QUERY([Accounts];[Accounts]Entered<(Current date 30))
 For($vlRecord;1;Records in selection([Accounts])) ` Loop once for each record
    CREATE RECORD([Archive]` Create a new archive record
    [Archive]Number:=[Account]Number ` Copy fields to the archive record
    [Archive]Entered:=[Account]Entered
    [Archive]Amount:=[Account]Amount
    SAVE RECORD([Archive]` Save the archive record
    NEXT RECORD([Accounts]) ` Move to the next account record
 End for
 DELETE SELECTION([Accounts]) ` Delete the account records

 
PROPERTIES 

Product: 4D
Theme: Records
Number: 68

This command changes the currrent record

 
INDEX

Alphabetical list of commands

 
HISTORY 

Created: < 4D v6

 
SEE ALSO 

ADD RECORD
MODIFY RECORD
SAVE RECORD