Its quite an interesting thing.
Seems that Item property of Form.Controls collection is quite intelligent to return recordset field when no control has the name passed as argument.
Example.
[SomeForm] has a RecordSource but no control.
? Forms!SomeForm.Controls.Count
0
? Forms!SomeForm.Controls!SomeField
<FieldValue>
? TypeName(Forms!SomeForm.Controls!SomeField)
AccessField
that is hidden class in Access library
And even more interesting.
Access creates property SomeField in Form_SomeForm class quite intelligently.
If [SomeForm] has a control bound to [SomeField], then the property is declared to return the control object. Otherwise it is declared to return AccessField object. Anyone can easily check this in Object Browser.
Summary.
- if a form bound to query/table doesn't have a control with the name same as of recordset field, then references like
Me.SomeField
and
Me!SomeField
will return AccessField object - if a form bound to query/table has a control with the name same as of recordset field, then references like
Me.SomeField
and
Me!SomeField
will return the control object