Klatuu
The statement
" ...Me! and Me. are the same ..."
is not entirely correct. For example, if the Form's (or Report's) has a
Control "Name" (OK, we know to avoid it but new users don't) then:
Me.Name refers to the name of the Form
Me!Name refers to the (value of) the Control "Name".
Basically the Dot operator "." refer to a Property of the Object (Me, the
Form in this case) while the Bang operator "!" refers to an item in a
Collection.
When we use:
Me!Name
we actually take advantage of the *default* Property "Controls" of the Form.
The full syntax would have been
Me.Controls.Item("ControlName")
Using the Bang to refer to an item in the Controls and omit the explit
"Controls" since it is the default Property of Me / Form, we end up with
Me!ControlName
The confusing part is that Access automatically creates a (custom???)
Property for each Control on the Form (and Field in the RecordSource) using
the ControlName as the Property name whenever possible. This Property
refers to the same Control. Thus, when we use:
Me.ControlName
we actually use the Property automatically creates by Access to refer to the
Control.
In the example at the beginning, "Name" is already an inbuilt Property so
Access couldn't create a second Property "Name". This in this case, Me.Name
and Me!Name actually refer to 2 different things altogether.
There are a few good article on Bang vs Dot but I don't have them handy.
Search Google ... if you are interested.
--
HTH
Van T. Dinh
MVP (Access)
Klatuu said:
That looks backwards. The one you say doesn't work really should.
The difference between . and ! is
. is to indicate a property or method of an object
! is to indicdate a user defined object.
You will note that Me. is used a lot. That is because Me is a shortcut to
refer to the current form or report and accepts either. Me! and Me. are
the
same; however, most of us use Me. because when you are coding and use the
.
you get a drop down of all the objects, properties, and methods associated
with the form. If you use ! you do not.
So,
=[Forms]![frm_Families]![frm_CaseNotes_subform].[Form].[noteid]
^
The form is user defined
=[Forms]![frm_Families]![frm_CaseNotes_subform].[Form].[noteid]
^
This is a user defined control on the form
=[Forms]![frm_Families]![frm_CaseNotes_subform].[Form].[noteid]
^
This is a form object of the subform. It
is not referred to
by name, but there is only one form bound
to the subform
control using the Source Object property.
=[Forms]![frm_Families]![frm_CaseNotes_subform].[Form].[noteid]
^
This is where I am
confused. I think the ! should
work because you are
referring to a user
defined object on the
form.
Kelvin Beaton said:
This one works,
=[Forms]![frm_Families]![frm_CaseNotes_subform].[Form].[noteid]
This one does not.
=[Forms]![frm_Families]![frm_CaseNotes_subform].[Form]![noteid]
MS Access Expression Builder created this one. It doesn't work either
Forms![frm_CaseNotes_subform]![NoteID]
How would I know to use a "." instead of a "!" ?
I'm using this string for the default value in a popup form so I can link
the records together...
Thanks
Kelvin