OK. Here goes. A little intro to programming in VBA and the structures you can work with.
Most code in VBA is instigated by events. There are various objects (such as forms; reports; controls on either forms or reports; etc; etc). Typically objects have various events associated with them. An event can be considered as a trigger for starting specific relevant code - generally termed an Event Handler Procedure.
I won't go into too much detail of all the possible events for all the possible objects as they are really far too numerous to mention. To put this in context though, a report has various sections, each of which has a
Format event associated with them. Forms don't have any objects with a
Format event as far as I'm aware, so this should be considered exclusively for reports.
When assigning code to an event, what you need to do is the following (to start you off right) :
- Open the containing object in Design Mode (if the object is a form or report then it won't be contained).
- Select the object (control; section; etc).
- Show Properties and select the Event from the list.
- The value will have a drop-down and the value "[Event Procedure]" will be available. Select this and click on the ellipsis button to the right.
- This will switch to the IDE (Integrated Development Environment) and create a procedure shell for you to populate with your code.