3.4. Using Access Collections and Objects

Earlier in this chapter, you briefly explored the difference between an object and a collection. To recap, collections can contain multiple objects. For example, you might use a forms collection to loop through all forms in the project, whereas you would refer to a particular form object when you wanted to deal with that specific form only.

Now that you have mastered the basic concepts of object-oriented programming and understand that objects are different from collections, let's look at some of the most useful collections and objects that come with Access. The examples in this section are by no means an exhaustive list, but they provide you with the most common collections. A complete list can be obtained in the Visual Basic help documentation from the Visual Basic Editor.

The Application object is at the top of the Access object model and refers to the active Access application. It contains all other objects and collections. The Application object contains several child objects that are very useful. Several Application object examples will now be described.

3.4.1. The Forms Collection and Form Object

The Forms collection of the Application object contains all forms in the application. A Form object refers to a specific form in the Forms collection. Let's look at an example.

Try It Out: Using the Forms Collection and Form Object

You can use the Forms collection and Form object to obtain a list of all the open forms in the application. ...

Get Beginning Access™ 2007 VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.