Example of setting the value of a property in response to an event

Microsoft Office Access 2003

Show All Show All

Example of setting the value of a property in response to an event

You can set the value of a property based on a value in the current record by running a macro or an event procedure in response to the form's Current event. For example, you might want the DateDue control on an Orders form to be hidden if the order is already paid (if the value of the Paid control is Yes or True).

To run a macro, set the form's OnCurrent event property to the name of the macro (HideDateDue) that sets the DateDue control's Visible property to No if the value of the Paid control is Yes.

Set a value based on an event

Callout 1 If the value of the Paid control is Yes ...

Callout 2 ... the macro sets the DateDue control's Visible property to No.

To use an event procedure, add the following Microsoft Visual Basic code to the Form_Current event procedure:

If Me![Paid] = True Then
    Me![DateDue].Visible = False
Else
    Me![DateDue].Visible = True
End If