Microsoft Office Tutorials and References
In Depth Information
Working with Visual Basic Editor
Figure 1-14:
Help for the
DoCmd
object.
Referring to objects and collections
Objects in the object model all have a syntax that works like this: You start
with the largest, most encompassing object and work your way down to the
most specific object, property, or method. The process is sort of like
following a path to a filename, as in C:\My Documents\MyFile.doc; you start
with the largest container (disk drive C:) and go down to the next container
(the folder named My Documents) and then to the specific file (MyFile.doc).
The Application object, for example, refers to the entire Access
program. It includes a CurrentProject object. If you were to look up the
CurrentProject object in the Object Browser and view its help window,
you’d see that CurrentProject houses several collections, including one
named AllForms. The AllForms collection contains the name of every
form in the current database. The AllForms collection in turn supports a
Count property. That property returns the number of forms in the collection.
Book VIII
Chapter 1
Suppose that you have a database open, and that database contains some
forms. If you go to the Immediate window, type
? Application.CurrentProject.AllForms.Count
and then press Enter, the Immediate window displays a number matching
the total number of forms in the database.
At the risk of confusing matters, typing the following line in the Immediate
window returns the same result:
Search JabSto ::




Custom Search