4D v16.3

CREATE RECORD

Home

 
4D v16.3
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 aTable, 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.

Note: This command does not require aTable to be in read/write mode. It can be used even when the table is in read-only mode (see Record Locking).

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



See also 

ADD RECORD
MODIFY RECORD
SAVE RECORD

 
PROPERTIES 

Product: 4D
Theme: Records
Number: 68

This command changes the currrent recordThis command can be run in preemptive processes

 
HISTORY 

Created: < 4D v6

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)