Gets the initial field contents (before data entry).
The .INITIAL_VALUE_GET() method returns the initial value of the field referenced by the object pointer. The initial value is the value before any edits have been made to the field. The type of Field_Value returned depends on the field's type. Character and memo fields return character strings; date, numeric, and logical fields return values in their corresponding field types. This method is useful if you want to determine if the user has changed a field's value when the user edits a record. It is also a way to see if the current record is "dirty", or needs to be saved.
The following function returns .T. or .F. depending on whether the value in a field on a form has changed.
function field_changed() as L init = this.field_get().initial_value_get() final = this.field_get().value_get() if (init <> final) then field_changed = .T. else field_changed = .f. end if end function
The following function can be placed in the onDepart event of a field on a form. It will cause the field to display in red if the user made a change to that field.
function set_font(changed_color as C, not_changed_color as C) as N if field_changed()then this.font.color = changed_color else this.font.color = not_changed_color end if end function
The following script is placed in a field's onDepart event. It shows the field in Red if it has changed.The following script is placed in a field's onDepart event. It shows the field in Red if it has changed.