About Adding Code to a Control (VBA)

After a control has been added to a form, you can edit the code for an event that is triggered by a control when a user interacts with it.

Now that you have your form looking the way you want, it is time to add some code behind your controls. To open the Code window for a control simply double-click on the control in the Form window. The Code window will open, with a subroutine created for that control and its default event.

You can add code to the default event, or choose a different event from the event drop-down list at the top-right corner of the Code window.