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).




Beginning Access 2007 VBA
Beginning Access 2007 VBA
ISBN: 0470046848
EAN: 2147483647
Year: 2004
Pages: 143

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net