AEU27: Using VBA to create a class based on a table (Adolph Dupré)
ฝัง
- เผยแพร่เมื่อ 9 มิ.ย. 2024
- In this session, Adolph Dupré discussed some powerful techniques for using class modules.
He explained when you may want to use classes instead of User Defined Types (UDT). For example to manage the data in unbound forms.
Adolph then demonstrated VBA code to create class modules from tables and use the class created to populate/navigate/update a simple unbound form.
A PDF of the presentation together with the sample database is avaqilable for download at www.isladogs.co.uk/aeu-27
Times:
00:00 Welcome from Colin
00:54 Adolph's intro
01:27 Presentation starts
02:01 What's a class object in Access?
03:20 Some more benefits of classes
04:29 MVC architecture
05:37 When to consider using a class
07:08 Example database - table & field naming convention
08:26 Review of class module code based on a table
10:49 Explanation of function to create class module from a table
14:05 Run function - new class created instantly
14:44 Example 1 - use class with form
17:39 Code behind the unbound form
21:39 Q1: Melvin - What if you use multiple tables for your form?
22:46 Q2: Ben - Can this be ported to Excel?
23:16 Adrian/Neil/Adolph - Discussion on the automatic population of the ID field in Access / SQL Server etc
27:10 Use of boilerplate code Find+Replace to simplify code writing
29:48 Example 2 - create class for large table with many fields
31:20 Q3: Neil/Ade -Could use public variables instead of Lets/Gets
33:33 Q4: Tim F - Lets/Gets allow for code validation checks to be added
34:43 Adolph - More on the ID field
35:17 Conclusion and thanks
36:26 Download links
36:45 Next month (Wed 5 June): Colin Riddingtom - IMEX Data Tasks & Extended File Properties
38:05 Further comments about using code to create code
38:40 Future events - download an .ICS calendar file to schedule future meetings in Outlook
39:52 Access Lunchtime meeting on Tues 30 April discussed new Discord server channel for Access: / discord
41:12 Call for AEU presenters in 2025
41:28 Previous AUG Europe video playlist on TH-cam: th-cam.com/users/playlist?list...
42:19 End - วิทยาศาสตร์และเทคโนโลยี
Thanks Adolph and Colin. I enjoyed the presentation and look forward to reviewing the code in the sample database. I like the idea of using code to generate code -- a time saver.
I agree. Its a very powerful technique that I've used in several apps, though in my case to create standard module code
I used it atleast 5 times last week. Saved Numerous hours.
I had to view it after, as I forgot when it was on. Enjoyed it very much.
Glad you enjoyed it. You could download the calendar file from the website. It will create an Outlook appointment for each meeting
Hope you make the next one.
Many thanks to Adolph for an interesting presentation using code to create code! This was a very easy way for those unfamiliar with class modules to understand how and why they are very useful.
Glad to have presented to my fellow programmers.
Many thanks. Good idea.
Glad you enjoyed it.