Module level variables

It is common to create a big wall of declaration in a module such as this:

While the code will compile and work fine, the discoverability and naming of the module level variables does become difficult and unwieldy. To help cut down on this ambiguity, it is recommended to create a private user-defined type instead.

Note the This variable which holds the UDT. That enables us to then refer to variables in the module in very similar manner to how we can use Me — for example:

Or,

By consistently using This UDT to hold all module-level variables, the naming and references is now much clearer and easier to understand. You do not have to wonder whether strCompanyname is a module-level variable or a private variable scoped to a specific procedure and because it’s in a UDT, shadowing cannot happen since you can simply disambiguate the reference.