Create a macro
Create an event procedure
Events and Event Properties Reference
Find out when events occur
Run a macro or event procedure for an event on a form, report, or control