Reputation: 1216
While programming in MS Access, there are certain places where an object is referred by !
operator and its property by .
operator.
For example,
Forms![Form Name].Visible
I was just wondering, is there any specific way to know what is what? I mean how can we be sure if !
is to be used or .
is to be used?
Also, is there any specific reason, why two different symbols are used for objects and properties?
Upvotes: 2
Views: 350
Reputation: 4069
A period is always used for properties & methods.
ex: recordset.MoveNext
An exclamation mark is used for child objects. The most common child object you will use is the field of a table.
ex: recordset!fieldname = "John"
In your example above, [Form Name] is a form that is a child of the forms set (which includes all forms). The [] is used for objects with spaces.
Warning: Access is fairly tolerant and will often allow a period to be used instead of an exclamation mark.
ex: recordset.fieldname = "John"
It's bad coding, but I give the example so you won't be confused when you see it.
Upvotes: 4