table.MOVE_RECORD_TO Function

Syntax

Result_Flag as L = Table.Move_Record_To(C Target_table_name )

Arguments

Target_table_name

The name of the table to receive the record.

Description

Moves the current record to another table with the same structure.

Discussion

The <TBL>.MOVE_RECORD_TO() method moves 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 and then the record in the current table is deleted. If the record was successfully moved, Result_Flag is .T. (TRUE). If the record was not moved 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 moved. 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 moves record 3 to "old_customers".

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

See Also