Objects Displayed in VBA Environment in MS Access

Objects Displayed in VBA Environment in MS Access

This MSAccess tutorial explains what objects are displayed in the VBA environment in Access (with screenshots and step-by-step instructions).

Objects displayed in the Project Explorer

Objects Displayed in VBA Environment in MS Access
Objects Displayed in VBA Environment in MS Access

The next important aspect to discuss is what objects appear in the Project Explorer.

At first glance, you’d assume that all of the Forms, Reports and Modules that you create will automatically appear in the Project Explorer. But this is not true. The VBA environment only knows about the objects that you tag as “having a module”.

So by default, all Modules will appear in the Project Explorer, but not all Forms and Reports necessarily will.

A Form will only appear in the Project Explorer if the Form’s “Has Module” property is set to “Yes”. In this example, the form called frmProducts has the “Has Module” property set to “Yes” so it will appear in the Project Explorer.

image 132
Objects Displayed in VBA Environment in MS Access 5

Similarly, a Report will only appear in the Project Explorer if the Report’s “Has Module” property is set to “Yes”. In this example, the report called rptProducts has the “Has Module” set to “Yes” so it also will appear in the Project Explorer.

image 133
Objects Displayed in VBA Environment in MS Access 6

Now, you’re probably asking yourself, “How come some of the forms and reports in my Access database have the “Has Module” property set to “Yes” and others don’t?”

Well, anytime that you invoke the Code Builder in a Form/Report, Access automatically sets Form/Report’s “Has Module” property to “Yes”.

image 134
Objects Displayed in VBA Environment in MS Access 7

Therefore, if you want to reference one of your Forms or Reports in the VBA environment, you may need to manually go to the Form/Report’s Properties window and set the “Has Module” property to “Yes”.

Congratulations! You’ve just completed the tutorial on understanding the VBA environment.