I have quite a few instances where I start with a basic subform, then I have 3 other subforms which build on it, each adding some different elements to the basic ones. This means that I have a code page for each subform, with lots of repetition. Is it OK to put the common elements into a separate module, and leave only the additional code relevant to each subform on its code page? Are there any performance issues with this?
Share
Regarding the last part of your question, “Are there any performance issues with this?“
There are 2 consequences I’m aware of:
As a hypothetical example, imagine you have a form with a tab control. That tab control contains 10 pages, and each page contains a subform. If those subforms include copies of the same VBA code, that common code must be loaded again for each subform. That takes time and increases memory use.
If you move the common code to a standard module and reference it from your subforms, you need load it only once … reducing both form load time and memory consumption.
So the net result is that the approach you’re considering could make your application more responsive … which may lead to happier users.
However, even if that approach does not yield a noticeable performance improvement, I would still do it anyway because it means you will need maintain only one copy of the common code.