beforeGetValue
Topic group Related topics Example
Event fired when reading a field’s value property, which returns its apparent value.
Parameters
none
Property of
Field (including DbfField, PdxField, SqlField)
Description
By using a field’s beforeGetValue event, you can make its value property appear to be anything you want. For example, in a table you can store codes, but when looking at the data, you see descriptions. This effect is called field morphing. The beforeGetValue event is also the primary way to set up a calculated field.
A field’s beforeGetValue event handler must return a value. That value is used as the value property. During the beforeGetValue event handler, the field’s value property represents its true value, as stored in the row buffer, which is read from the table.
Be sure to include checks for blank values—which will occur when a beginAppend( ) starts—and the end-of-set. Any attempt to access the field values when the rowset is at the end-of-set will cause an error. Return a null instead.
beforeGetValue is fired when reading a field’s value property explicitly and when read to update a dataLinked control. It does not fire when accessed internally for SpeedFilters, index expressions, or master-detail links, or when calling copyToFile( ).
To reverse the process, use the field’s canChange event.
Note
Morphed and calculated fields sometimes require display widths that are larger than their field widths. To avoid truncating the display, use a picture that represents the field’s maximum size.