Skip to main content
Version: Next

CREATE RECORD

CREATE RECORD {( aTable )}

ParameterTypeDescription
aTableTableTable for which to create a new record, or Default table, if omitted

Description

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

Command number68
Thread safe
Changes current record