Change Event

Applies To

Combo Box Control, Text Box Control.

Description

The Change event occurs when the contents of a text box or the text portion of a combo box changes. Examples of this event include entering a character directly in the text box or combo box or changing the control’s Text property setting using a macro or Visual Basic.

Notes

  • Setting the value of a control using a macro or Visual Basic doesn’t trigger this event for the control. You must type the data directly into the control, or set the control’s Text property.
  • This event applies only to controls on a form.

Remarks

By running a macro or executing an event procedure when a Change event occurs, you can coordinate data display among controls. You can also display data or a formula in one control and the results in another control.

The Change event doesn’t occur when a value changes in a calculated control or when you select an item from the combo box list.

Note

Note A Change event can cause a cascading event. This occurs when a macro or event procedure that runs in response to the control’s Change event alters the control’s contents — for example, by changing a property setting that determines the control’s value, such as the Text property for a text box. To prevent a cascading event:

  • If possible, avoid attaching a Change macro or event procedure to a control that alters the control’s contents.
  • Avoid creating two or more controls having Change events that affect each other — for example, two text boxes that update each other.

Changing the data in a text box or combo box using the keyboard causes keyboard events to occur in addition to control events like the Change event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown KeyPress BeforeInsert Change KeyUp

The BeforeUpdate and AfterUpdate events for the text box or combo box control occur after you have entered the new or changed data in the control and moved to another control (or clicked Save Record on the Records menu), and thus after all of the Change events for the control.

The NotInList event occurs for combo boxes for which the LimitToList property is set to Yes after you enter a value that is not in the list and attempt to move to another control or save the record. It occurs after all the Change events for the combo box. In this case, the BeforeUpdate and AfterUpdate events for the combo box don’t occur, because Microsoft Access doesn’t accept a value that is not in the list.

See Also

BeforeUpdate, AfterUpdate Events; Enter, Exit Events; GotFocus, LostFocus Events; KeyDown, KeyUp Events; KeyPress Event; NotInList Event; Open, Close Events; Text Property.