Responding to Control Events in a Class

Everyone designing Microsoft Access forms sooner or later realizes that it takes a long time to customize some of the controls placed on the form. It's no wonder then that once the control is working correctly, if another form requires a control equipped with the same functionality, there is a tendency toward copying the control and its event procedures to a new form. If you followed this chapter carefully you already know a better (and a neater) solution. By using the WithEvents keyword you can create an object variable that points to the control raising the events. Instead of responding to control events in the form module, you will react to these events in a different location: a standalone class module. This lets you write centralized code that is easy to implement in other form controls of the same type.

Part IV

Suppose you need a text box that converts lowercase letters to uppercase and disallows numbers. Hands-On 27-1 demonstrates how to create a text box with these features and hook it up with any Microsoft Access form.

0 0

Post a comment