Microsoft Access 2.0 adds modules for forms and reports to the global modules that existed in Microsoft Access 1.x. Form and report modules are "built in" to forms and reports. Every form or report in Microsoft Access has a module automatically associated with it. This module is used for code that responds to events on the form or report. This new feature is referred to as "Code Behind Forms" or CBF.
CBF in Microsoft Access is very similar to CBF in the Microsoft Visual Basic® programming system. Both support "event procedures," which are Basic procedures that are run in response to events. These event procedures follow the same syntax in both Microsoft Access and Visual Basic, as the following examples show:
Sub Form_Open( Cancel As Integer ) 'User code for responding to open for a form in Microsoft Access End Sub Sub ControlFoo_KeyPress ( KeyAscii As Integer ) 'User code for responding to press of a key in the control 'named ControlFoo. End Sub
These procedure templates are generated for you by Microsoft Access. All you need to do is add your code to respond to the event.