A really dumb question...

  • Thread starter Thread starter Sandra
  • Start date Start date
S

Sandra

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
 
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?

Conventionally, you use the exclamation for file field or control names, and
the dot for methods and properties. So in your first example, Owner is
either a field or control name and you are referring to the text property of
that field. In the second Me is a form or report, that has a detail section
(property) that has an attribute of backcolour which you are setting to a
particular amount.

In later versions of Access, it seems you can use the dot always and forget
about the exclamation.
Marc
 
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
 
Just to add to the other responses, you'll go a long way remembering
bang(!) if you named it, dot(.) if you didn't
 
In later versions of Access, it seems you can use the dot always and
forget

In all versions of Access, you can use the dot and forget about
the exclamation mark when referring to controls on a form.

In earlier versions of Access, you could ALSO use the dot when
referring to fields of a recordset.

(david)


Marc said:
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?

Conventionally, you use the exclamation for file field or control names, and
the dot for methods and properties. So in your first example, Owner is
either a field or control name and you are referring to the text property of
that field. In the second Me is a form or report, that has a detail section
(property) that has an attribute of backcolour which you are setting to a
particular amount.

In later versions of Access, it seems you can use the dot always and forget
about the exclamation.
Marc
 
Back
Top