====== CALCULATE event ====== ==== Description ==== Calculates fields based on the control or cell (in an edit table) losing focus. ==== Syntax ==== //bforward// = **CALCULATE**(//ctrlentID//, //ctrlclassID//, //ctrlcolumn//) ==== Parameters ==== CALCULATE accepts arguments for the following parameters. ^Parameter^Description^ |//ctrlentID//|Has the format //WindowName.ControlName//, where //WindowName// is the identifier of the window that contains the affected control, and //ControlName// is the identifier of the control. Notice that a period separates the two values.| |//ctrlclassID//|The type of control that recognizes the event. This event is applicable only to a control bound to a symbolic from the primary table.| |//ctrlcolumn//|The column number.| ==== Returns ==== True or false. If false, the program execution returns to the calling procedure. If true, the event processing goes to the next level. ==== See Also ==== [[dict_depend|Dict_Depend]], [[calculate|Calculate()]] , [[Braces_operator|{}]] ==== Remarks ==== Occurs after a [[lostfocus_event|LOSTFOCUS event]] or [[poschanged_event|POSCHANGED event]] (for an edit table). The CALCULATE event occurs when there is a relationship between two controls (or columns, in an edit table) based on a primary table. The CALCULATE event will only occur if there is a control that is based on a calculated field which is dependent on the control that is losing focus. === Recalculating All Controls === Example code to recalculate all controls on a form, using the [[ctrlmap|CTRLMAP property]]. After all controls are known, loop through and send the CALCULATE event to all the controls. declare subroutine send_event window_controls = @@window->ctrlmap window_controls_count = count(window_controls, @fm) + (window_controls #%%''%% ) for i = 1 to window_controls_count send_event(window_controls, "CALCULATE") next i === Recalculating a Data Bound Control Based on a Change in an Edit Table === Note: To enable a data bound control based on a symbolic field to recalculate if a value in an edit table changes, update the [[defprop|DEFPROP property]] (not the [[array|ARRAY property]]) of the edit table. Then send a CALCULATE event to the data bound control, as follows: Stat = Send_Event( DataBoundControlName, "CALCULATE" )