Common Control Events

Here are some events on form controls (such as text boxes, combo boxes, command buttons, etc.) that are commonly used.

□ Control—On Click: This one is obvious; it fires when the control (most likely a command button) is clicked. This is where you put the code to run when the user clicks a button.

□ Control—Before Update: The Before Update event is very useful for controls that contain values, such as text boxes and combo boxes. It fires just before a change to the control is committed, so you have a chance to edit the new value of the field. If this event is cancelled, the control will revert to its previous value.

□ Control—After Update: This event fires after a change to the control is made. This is a handy time to control the next field to receive the focus or to update other fields in response to this one. This technique is explained in the section Cascading Combo Boxes in Chapter 14, "SQL and VBA."

□ Control—On Double Click: This event fires when a control is double-clicked. This is useful when you want to provide a method of drilling down to a detail form from a read-only index form. Make sure you add the code to open the detail form to every double-click event of every field in the detail section.

0 0

Post a comment