Reference to subform

T

Todd K.

I am trying to call up a value from a subform and I have the following code:

Dim fld as String
Dim frm As Form

Set frm = Forms![MyMainForm]![MySubForm]

fld = frm.MyField

When I run it, it gives me an error saying it can't find the field
"MySubForm".
 
K

Ken Snell \(MVP\)

MySubForm must be the name of the subform control (the control that actually
holds the source object serving as the subform), which may or may not be the
same name as the form that is being used as the subform.
 
D

Douglas J. Steele

Not only that, but to instantiate a reference to the form being used as a
subform, try:

Set frm = Forms![MyMainForm]![MySubForm].Form


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ken Snell (MVP) said:
MySubForm must be the name of the subform control (the control that
actually holds the source object serving as the subform), which may or may
not be the same name as the form that is being used as the subform.

--

Ken Snell
<MS ACCESS MVP>

Todd K. said:
I am trying to call up a value from a subform and I have the following
code:

Dim fld as String
Dim frm As Form

Set frm = Forms![MyMainForm]![MySubForm]

fld = frm.MyField

When I run it, it gives me an error saying it can't find the field
"MySubForm".
 
T

Todd K.

Excellent, thank you gentlemen - it works perfectly now.

Douglas J. Steele said:
Not only that, but to instantiate a reference to the form being used as a
subform, try:

Set frm = Forms![MyMainForm]![MySubForm].Form


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ken Snell (MVP) said:
MySubForm must be the name of the subform control (the control that
actually holds the source object serving as the subform), which may or may
not be the same name as the form that is being used as the subform.

--

Ken Snell
<MS ACCESS MVP>

Todd K. said:
I am trying to call up a value from a subform and I have the following
code:

Dim fld as String
Dim frm As Form

Set frm = Forms![MyMainForm]![MySubForm]

fld = frm.MyField

When I run it, it gives me an error saying it can't find the field
"MySubForm".
 
Top