table.PREVIOUS_RECORD Function

Syntax

Record_Number as N = Previous_Record()

Description

Returns the previous record data entry was performed on.

Discussion

The <TBL>.PREVIOUS_RECORD() method returns the Record_Number that was current just before the user began entering a new record (by clicking the New Record icon on the toolbar, selecting the Enter New Record command, executing a script with the PARENTFORM.NEW_RECORD() method, etc.). For example, say that a table has 100 records. Record number 4 currently has focus. The user presses the new record icon to begin entering record 101. At this point <TBL>.PREVIOUS_RECORD()would return 4, since that is the record that had focus immediately prior to entering the new record. Record is not set if the new record is entered in an Xbasic script using the <TBL>.ENTER_BEGIN() method.

Example

This code is attached to a button on a form. It fills in certain fields from the record that was current before the user began entering a new record.

if (parentform.mode_get()<> "ENTER") then
    ui_msg_box("Error", "Must be in enter mode")
    end
end if
tbl = table.current()
record = tbl.previous_record()
filename = tbl.filename_get()
tbl2 = table.open(filename)
tbl2.fetch_goto(record)
lastname.text = tbl2.lastname
firstname.text = tbl2.firstname
tbl2.close()

See Also