4.3. Create Custom Methods for Existing Objects
In addition to custom procedures, custom methods can also be created for existing objects by using public sub procedures or functions.
4.3.1. Using Public Sub Procedures and Functions
Custom methods can be created just as you created methods for your own objects, only you add a public sub procedure or function to the existing object. Now add a new method for the frmCarDetails form to see how this works.
Try It Out: Adding New Method for the frmCarDetails Form
|
4.3.1.1. How It Works
First, you added the new method to the existing frmCarDetails form. Then, when you referred to frmCarDetails in code using the me keyword, you saw that the custom method you just added was in the drop-down list along with the custom property you just created and the original properties and methods. Just like properties, methods can be added to nearly any existing object.
Get Beginning Access™ 2007 VBA now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.