Here is the place where you can save a lot of time typing code. As you know, VBA is based on Visual Basic. The “Visual” part of that
Figure 7-5:
Properties window in alphabetical order
Select the Categorized tab to see the items
Figure 7-6:
Properties window in categorized order
One of the most important tools you will be working with is the Object Browser. This lets you examine all of the objects available to the project. Notice the word “available.” You may or may not use them. Within each object, you will see the properties,
It is worth spending a bit of time learning about this tool. While we’re at it, you will learn some of the terminology associated with objects.
Open the Object Browser by either selecting View Object Browser or pressing F2 . The Object Browser is shown in Figure 7-7.
Figure 7-7:
The Object Browser
Objects are entities in the computer’s memory. However, they have to come from somewhere. The source of an object is a
class
, which serves as a kind of template from which an object (which is also called
an instance of a class
) is created. On the left of the browser, you will see an
The right side of the browser shows the members of the class. Classes have three main types of members: properties, methods (subs and functions), and events (which are a special kind of sub).
Properties are
Figure 7-8:
A property in the Object Browser
Once selected, you can see the description of the property located at the bottom of the browser. Notice that this property returns a Boolean value of either True or False. The form will either allow deletions or not.
{% if main.adsdop %}{% include 'adsenceinline.tpl' %}{% endif %}A method (which is either a function or a sub), is another type of member. As an example, leave the Form_frmCustomer class selected in the left pane of the Object Browser, then select the GoToPage sub in the right pane. Notice the icon to the left of it and how it is different from the property icon. Also, notice the description at the bottom of the browser, shown here:
This is described as a sub. The documentation also shows the parameters the sub will accept, as well as their type and order.
These class modules are not just
You can also see the list of available libraries by selecting the library list located at the top of the browser, as shown here:
Again, if you do not see the same thing, do not worry; we will be fixing that shortly.
You also have the ability to search the libraries for a particular member. As an example, let’s say that we wanted to see which class files have the sub GoToPage. Referring to Figure 7-9, I have selected All Libraries and typed GoToPage in the field below it. I then clicked on the search icon to the right of the field. The results are shown in the Search Results window. In this case, several class files in the Access and Word libraries contain that sub.
Figure 7-9:
A library search