Recalc Method

Microsoft Access Visual Basic

Recalc Method

       

The Recalc method immediately updates all calculated controls on a form.

expression.Recalc

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks

Using this method is equivalent to pressing the F9 key when a form has the focus. You can use this method to recalculate the values of controls that depend on other fields for which the contents may have changed.

Example

The following example uses the Recalc method to update controls on an Orders form. This form includes the Freight text box, which displays the freight cost, and a calculated control that displays the total cost of an order including freight. If the statement containing the Recalc method is placed in the AfterUpdate event procedure for the Freight text box, the total cost of an order is recalculated every time a new freight amount is entered.

Sub Freight_AfterUpdate()
    Me.Recalc
End Sub