Summary

team lib

Events are vitally important to Windows and Access. As developers we quickly learn how to build event handlers in forms for the various form and control events we use to customize our forms and, by now, events are probably old hat.

What we have done in this chapter is taken event handling to the next level and shown you how to sink events directly in a class of your own making. This ability combined with your evolving knowledge of classes will undoubtedly make you a better programmer. Class objects allow you to encapsulate behaviors and properties for objects so that you can use these behaviors throughout your system with just a few simple lines of code to instantiate the class.

We have learned how to:

  • Use the keyword WithEvents to allow our class to sink events for an object.

  • Build an init procedure to accept references to objects and save them in a class's local variable.

  • Build the event sink itself and apply logic to cause the event sink to perform some action.

  • Hook the class into a form, initialize in Open, and clean up in Close .

  • Raise an event of our own in order to signal to a listener that something has happened , passing parameters to the listeners if we need to.

As you've seen, this is mostly just an extension of information you learned in earlier chapters. You already know how to handle events generated by objects, and how to build classes. This chapter simply put the two concepts together and showed how to handle events in any class you want rather than only in form classes. However it truly is a revolutionary step for most developers, giving them the power to do things that simply weren't possible before.

 
team lib


Beginning Access 2002 VBA
Beginning Access 2002 VBA (Programmer to Programmer)
ISBN: 0764544020
EAN: 2147483647
Year: 2003
Pages: 256

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net