Skip to content

NewRecord Command

See Also: Understanding File Buffers and DDO Field Buffers, Lock, Reread, SaveRecord

Purpose

To allow preparation of the record buffer for creating a new record without clearing the buffer.

Syntax

NewRecord
table

table is the logical name or filelist number used to identify the table.

What It Does

NewRecord allows you to prepare the record buffer for the creation of a new record while retaining all existing data in the record buffer (with the exception of Recnum). This allows you to find an existing record and clone the information with a single line of code. You should then, of course, change data in uniquely indexed columns to avoid getting a duplicate record error when saving the new (cloned) record.

Example

Procedure Test2
    Open Customer
    Find Gt Customer by 1
    Lock
    NewRecord Customer
    Move 1001 to Customer.Customer_Number
    SaveRecord Customer
    Unlock
End_Procedure

In this example, an existing customer record is found. The NewRecord command is used to prepare the record buffer for creating a new record while retaining all information in the record buffer. Then, one column (Customer.Customer_Number) is changed and the new record is saved. The new record will have all the same information in it as the record that was found, with the exception of the column that was specifically modified.