table.RECORD_DATA_SET Function

Syntax

V Record_Data_Set(B Data)

Arguments

Data

A blob variable containing the record data prepared by <TBL>.RECORD_DATA_GET().

Description

Set all the feilds int the current record using data from a blob.

Discussion

The <TBL>.RECORD_DATA_SET() method copies all the field values from the blob variable, Record_Data, into the current record which must be in enter or change mode. Note : You can use PROPERTY_TO_STRING() and PROPERTY_FROM_STRING() to move data between tables with different structures.

Example

This script copies the current record to a blob variable. It then opens a table with an identical structure and pastes in a new record. The script is attached to a button on a form.

dim record_data as B
dim tbl as P
tbl = table.current()
record_data = tbl.record_data_get()
target = table.open("clone")
target.enter_begin()
target.record_data_set(record_data)
target.enter_end(.T.)
target.close()

A form has two buttons: "Copy record" and "Paste record" which allow a user to copy the current record and then navigate to another record and paste into this record. The following script is for the "Copy record" button:

dim shared blob as b
dim t as P
t = table.current()
blob = t.record_data_get()
'The following script is for the "Paste record" button:
response = ui_msg_box("","Are you sure you want to overwrite the existing data? ", UI_YES_NO_CANCEL)
if response = UI_YES_SELECTED then
     choice = "YES"
    elseif response = UI_NO_SELECTED then
      choice = "NO"
    else
      choice = "CANCEL"
end if
If case upper("YES") == upper(choice)
      dim shared blob as b
       t = table.current()
       mode = t.mode_get()
    If mode = 0   'Form is in view mode
      t.change_begin()
      t.record_data_set(blob)
       t.change_end(.T.)
       parent.resynch()
    Else        'Form is already in change or enter mode
      t.record_data_set(blob)
      parent.commit()
       parent.resynch()
    end if
end if

See Also