Access, like most Windows programs, is an event driven application. This means that nothing happens unless it is in response to some event that has been detected by the application.
The steps are fairly straightforward:
- An event happens
- The event is detected by the application
- The application responds to the event
Although the obvious event for a button is the Click (On Click) event there are actually 12 possible events associated with a button.
To code an event:
Right click on the object or control you wish to program an event for. Go to properties and go to the Event tab. Choose the event you wish to code e.g. On Click for a button control. Click on the builder button (the one with three dots) and select Code Builder from the list. This will open the Visual Basic Editor with the opening and closing lines of the event procedure already coded. Everything you put between these two lines will execute when the button is clicked.
Every form and report object can have events programmed on them, as can all the controls in those same forms and reports.
Below are some of the more common events with details of when they occur:
There are many more events but these should get you started.