[FAQ] Referring to objects in Access: ! and . and ( (1 Viewer)

Status
Not open for further replies.

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:36
Joined
Feb 19, 2002
Messages
43,257
There are some things I would add.

The bang ! is used before user defined objects and the dot . is used before methods or properties. Within the class module for a form or report, both the controls and the fields of the recordsource belong to the fields collection. That is why they can be preceded by the . and have intellisense. Therefore, the syntax - Me.?? will bring up a list that includes both controls and fields. If the control and the field have the same name, as is the case when a wizard makes the form, there is only a single entry. when the control name is different from the field referenced in the controlsource, both are listed.

When you write code in a form or report's class module, use the "Me." qualifier to reference controls or fields. This results in what is called "early binding" and because of intellisense, you can easily see when you have used an invalid field or control name. If you use "Me!" (late binding), you won't see errors until runtime.

When you want to refer to fields on the main form, use the syntax, Me.Parent!yourcontrolname rather than the external control name reference style - Forms!Yourform!yourcontrolname.
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom