• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Defining Events

If you have worked with Access forms or reports, you have activated events. Every time you open or close a form and report, you activate the On Open and On Close events. The On Activate event occurs when the form becomes the active window. In contrast with many other object properties, event properties are initially left blank with no default values. If you set the event property to a macro, the macro runs when the event occurs. Let’s say you have a button on a form labeled Print Record. If you click this button when the form is open (not in Design view), the On Click event activates and runs the macro or procedure attached to the event. This procedure prints the current record of your form. If you want to issue a list of Visual Basic statements when a certain event occurs, you write a procedure to attach to the event. It should be no surprise that this is called an event procedure.

Controlling Events

Events also occur on controls in forms. This can be very useful for lookups and pick lists. For example, suppose you have a lookup value that you have just changed. You might have another field that needs to update to correspond to the updated field. For example, if the customer decides to buy two items instead of one, the Extension field (which is computed by multiplying the quantity times the price) must change to reflect the new value.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint