Access VBA Macro Programming

(Joao Candeias) #1
This gives you a code area to write your VBA code against. Notice that in the drop-down
list in the top right-hand corner of the module window that your subroutine MyCode has now
been added. This is useful as a navigational facility. In complex applications where many
procedures exist in a module, this gives a useful alphabetical list of them.
If you intend to write any code for the event, then you must include these two statements
or you will get a compile error. Think of them as start and finish lines in a race—they tell the
compiler where the code starts and stops. If you do not want to write any code for that event,
you can delete them, but both must be deleted or you will get a compile error. The compiler
wants your code neat and tidy, which means it must be structured properly.
Currently, you have the start and finish of an event. Although there’s nothing between the
SubandEnd Substatements, the routine is still live and will fire when you click the Run
icon on the toolbar (green triangle pointing to the right) or pressF5. However, because there
is no code in the event, it will not do anything.

8 Microsoft Access 2010 VBA Macro Programming


Figure 1-4 Code window for an Access module
Free download pdf