Hi Sandra,
The Me keyword refers to the form in which the code is running.
The dot . notation is used to refer to _properties_ of the form, like
properties of any other object; hence
Me.Caption
Me.Detail.BackColor
The bang ! notation is a shortcut to the form's Controls collection, so
Me!Owner
corresponds to
Me.Controls("Owner")
In addition, however, the form exposes its controls and fields as
properties of itself. So
Me.Owner
also refers to Me.Controls("Owner") and - unlike the ! notation - lets
you use the Intellisense autocomplete feature in the VBE.
If you give the controls different names from the fields they are bound
to - e.g. a textbox txtOwner bound to the field Owner - both the control
and the field appear as properties of the form and - for some purposes -
as members of the form's collection of controls:
Me.txtOwner.Value 'value property of textbox,
Me.txtOwner.FontName 'name of font used in textbox
Me!txtOwner!Value 'same
Me!txtOwner!FontName
Me.Owner.Value 'value property of field
Me.Owner.FontName 'error: fields don't have fonts
Me!Owner.Value 'same
Similarly, if there's no control bound to a field, the field appears as
a property and can also be referred to as if it were a control.
As far as I can make out the only place where you need to use the !
notation is when using a parameter query that collects its parameters
from controls on a form:
Forms![Form Name]![Control Name]
I am just starting to work with event procedures and
almost everything so far I have copied and pasted from
the nice people on this forum or from other places, so I
am clueless about some of this.
What does the exclamation point mean in the syntax like:
Me![Owner].Text = ""
versus something like
Me.Detail.BackColor = 12615680
which has a period instead of the exclamation point?
TIA,
Sandra