Announcement

Collapse
No announcement yet.

Creating a Derived Field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a Derived Field

    Creating a Derived Field
    This example shows how to derive the age based on the date of birth entered into the field DOB. This code is placed in the onLostFocus method of the field DOB and will populate the variable AGE when the focus is removed from the DOB field only if a value is specified in the DOB field.

    In this example there are no restrictions on when this code will execute, so the age value will be re-calculated and updated in any data entry mode, anytime the field focus is removed from the DOB field. This includes Verify mode.

    DOB and AGE are both Numeric. DOB has a format and informat of mmddyy10.

    Example Code
    Code:
    /** OnLostFocus Method **/
    
    %include objfile;
    
    
    _OnLostFocus: method _self_:u:object;
    link createobj;
    ************************;
    ** Add user code here **;
    ************************;
    
    ** Calculate age based on DOB entered **;
    if dob.text > . then do;
        age.text=floor((date()-dob.text)/365.25);
    end;
    
    
    
    endmethod;
    Last edited by Greg Wagner; 02-10-2005, 03:03 PM.
Working...
X