O'Reilly logo

Beginning Access™ 2007 VBA by Denise Gosnell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.3. Ways to Refer to Objects

You should also know the various ways to refer to an object. Here are some examples:

Forms.frmTestObjects
Forms!frmTestObjects
Forms("frmTestObjects")
Forms(0)

Using the period (Forms.frmTestObjects) is my personal preference for most situations because you can see the list of available properties, methods, events, and constants as you type. You already saw this used with objects earlier in this chapter.

You can also refer to objects using the Me keyword as a shortcut. Me refers to the current object. So if you use Me in a form module, it refers to the form. Here is an example:

Me.txtDateOfBirth

An equivalent, but longer, version of the same statement is:

Forms.frmTestObjects.txtDateOfBirth

Only use the Me keyword when you want to refer to the existing object (not to a totally different object).

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required