If I may add to Wayne’s post.
Those demos were originally written for a very specific purpose, namely to simply see if I could do it. I would never use that technique in production code; it is simply a way to ‘knock up’ something for testing.
Two possible reasons come to mind…
1. When controls are created ‘on the fly’ there is no guarantee that they would be destroyed ‘on the fly’, that much you will need to test for yourself. You might get away with it for an hour, or six months, but eventually the application could crash due to ‘too many controls in the life of a form’. Under these circumstances an hour would be preferable to six months.
2. It requires that the form is opened in design view and that can’t happen in an MDE file. You would be locking yourself into and MDB file and that is not the way to go if you wish to hand over your application to some other party.
So please think very carefully about going down this path, it could be a waste of time.
Please don’t let this post stop you from trying, it’s a worthwhile endeavor, but the gains you get may not be just what you originally had in mind.
Edit to add.
The code that the code writes is something I do all the time and that’s what I learned.
If we have 3 Event Handlers then that is OK but if we have 400 Event Handlers then that is not OK. Somewhere between 3 and 400 the situation changes. Just when and where that situation changes is entirely up to the person that has to maintain it.
Regards,
Chris.