This month’s session was led by Ramachandran (APR) Pillai who did a deep dive into the use of class modules to streamline module code. Over the past few months, Ramachandran has published a series of 20+ articles on Reusing Form and Report Module VBA Code for New Projects starting with https://www.msaccesstips.com/2023/04/.... This contains links to all the later articles. He covered much of this material in this presentation. During the course of this session, you will learn how to make effective use of class modules to streamline form and report event code.
You can download a PDF of the presentation, together with the example Access databases from https://isladogs.co.uk/aeu-23/
NOTE: Due to technical issues, our presenter lost internet connection about half way through the session. We re-recorded the second half a few days later and included questions & answers from the session chat & later discussion. The final result is as close as possible to what was originally intended by our presenter.
Captions are currently available in 10 languages including Malayalam, Hindi, French, German, Spanish etc. These are auto translated so won't be perfect but may be useful to those for whom English isn't the primary.language.
TIMES:
0:00 Welcome and intro to a.p.r. pillai
1:10 Intro by a.p.r. pillai - background / website & today's topic
3:39 Demo Highlight Controls using standard approach adding code to the got focus & lost focus events for each control in the form module
5:09 Repeat using event procedures in standalone class module highlighting applies to additional controls with no new code
5:55 Class module code - one set of events only - applies to all form controls. Use of WithEvents
8:56 Corresponding code in form module initiates class module code as collection on Form_Load event and removes collection on Form_Unload event
11:26 Next step is to move initiation code to separate class module to allow it to be resused in multiple forms and stre amline form module code
12:40 Third form with all highlighting code in class module. Form module code now just one line in each of Form_Load & Form_Unload events. All other code in class module, Easier to maintain.
19:18 Sliide 3 - Summary / review - Wrapper classes / intermediary class / form class module - all class modules and instances loaded into memory while form open
20:41 Slide 4 - Understanding how object events are built in Access
22:27 Presenter lost internet connection.
22:32 New recording starts here
24:26 Slide 4 Summary : Event / RaiseEvents / WithEvents
25:22 Q1: Neil - Why use the form's Unload event to clean up instead of the Close event? Is it to make use of the Cancel argument? Or would the Close event be more robust?
26:17 Q2: Ade - Is it necessary to keep the Object alive in the collection after the changes have been made? Why not have the collection object in the class module? (CR: this was later covered in the third demo form)
28:10 Slide 5 - Detailed explanation of Object Event Declarations: Event / RaiseEvent / WithEvents
33:46 Slide 6 - Wrapper Class Template for stramlining textbox events
38:06 Slide 7 - 2 rules for using Event / RaiseEvent / WithEvents
40:11 Q3: - Neil / Ade: Is it really necessary to store the form reference in the class module when it can be derived from the control?
41:28 Comment by Chris: Alternative to class modules – add function name ([Form]) in property sheet.
Yes but needs to be added manually whereas with class module it is automatic
41:51 Q4 - Chris: Can class events pick up event parameters such as keycode in the keypress event?
42:52 Colin - thanks to a.p.r. pillai for an excellent presentation despite the internet connection issues
43:31 Back to original session: Slide with links to aticles related to this session
43:48 Web article https://isladogs.co.uk/aeu-23 with downloads for files for today's session
44:00 Link to the first of a.p.r. pilai's articles at https://www.msaccesstips.com/2023/04/...
44:43 Next month: Carlos Quintero - Top 10 advanced features of MZ-Tools
45:28 Carlos - outline of next month's session.
49:57 News of free prize & reduced price offer for next month. Be there (or be square!)
51:06 End