Microsoft Office Tutorials and References
In Depth Information
Understanding Objects and Collections
And so it goes, each Case statement modifying certain controls and
positioning the cursor based on the current value of the Payment Method control.
After you type the code, close the Code window and Visual Basic Editor to
return to your form. Then save the form, open it in Form view, and try out
your code.
If you have difficulty with your own code, you may find some of the debugging
techniques described in Chapter 6 of this minibook useful for diagnosing and
fixing problems.
Understanding Objects and Collections
Working with controls on a form or report from within a class module is
greatly simplified by the Me keyword, which refers to the form or report to
which the class module is attached. Things become more complicated when
you write code in standard modules. In a standard module, the keyword Me
doesn’t refer to anything because the module isn’t attached to any particular
form or report. The moment you step outside a class module, you have to
think more in terms of object models.
As we hope that you know, just about everything you work with in Access is
an object. Tables, queries, and forms are all objects. Some objects are very
much alike; tables are alike in that they all contain data. Forms are alike in
that they all present data from tables in a certain format. A group of like
objects forms a collection. All the tables within your database, for example,
represent that database’s tables collection.
In some cases, a single object may be a collection as well. A single form is
one object in the collection of forms, but it’s also a collection in its own
right — a collection of controls. Each control on a form is also an object in
its own right, but even a single control is a collection. A control has lots of
properties, as you can see on any control’s property sheet in Design view.
Figure 4-6 shows that a collection is a bunch of objects that have something
in common and that any given object can also be a collection.
Chapter 4
Search JabSto ::

Custom Search