table.COPY_RECORD_TO Function

Syntax

Result_Flag as L = Table.Copy_Record_To(C Target_table )

Arguments

Target_table

The name of the table to receive the copied record.

Description

Copies current record to another table with similar structure as current table.

Discussion

The <TBL>.COPY_RECORD_TO() method copies the current record in the source table referenced by <TBL> to the target table specified by Table_Name. Data is copied from each field in the source table to the corresponding field with the same name in the target table. If method returns .T. (TRUE) in the Result_Flag if the record was successfully copied. If the record was not copied then the method generates an error. For example, if the record you are trying to copy violates a field rule in Table_Name, it will not be copied. Use the ERROR_CODE_GET() and ERROR_TEXT_GET() functions to get the error message associated with the error. Table_Name can have more fields than the source table. However, at a minimum, it must have all of the fields in the source table, and they must be of the same type and size.

Example

This script copies record 3 to the "OLD_CUSTOMERS" table.

dim tbl as P
tbl_source = table.current()
tbl_source.fetch_goto(3)
on error goto failed_to_copy
result = tbl_source.copy_record_to("OLD_CUSTOMERS")
on error goto 0
if result then
    ui_msg_box("Result","Record was copied")
end if
end
failed_to_copy:
    ui_msg_box("Record not copied.", error_text_get(error_code_get()))
end

See Also