Referencing to a control on a subform

  • Thread starter Thread starter Jan T
  • Start date Start date
J

Jan T

Hi. I am using Access 2010 and have made a form frmOvertime with a
text box Control named txtEmpID. When I refer to this control I use
the following code:
lngEmpl = [frmOvertime ].Form![txtEmpID]. The code is in a standard
module and this works just fine.

However, when I add frmOvertime to my Navigationform (frmMAIN), as a
SubForm, Access cannot find my control? So I changed my code to
reference to lngEmpl = Forms!frmMAIN!frmOvertime .Form!txtEmpID but I
am stilling getting an error?

Any help to refer to this control, is very much appriciated?

Regards Jan T.
 
Hi. I am using Access 2010 and have made a form frmOvertime with a
text box Control named txtEmpID. When I refer to this control I use
the following code:
lngEmpl = [frmOvertime ].Form![txtEmpID]. The code is in a standard
module and this works just fine.

However, when I add frmOvertime to my Navigationform (frmMAIN), as a
SubForm, Access cannot find my control? So I changed my code to
reference to lngEmpl = Forms!frmMAIN!frmOvertime .Form!txtEmpID but I
am stilling getting an error?

Any help to refer to this control, is very much appriciated?

Regards Jan T.

When a form is embedded into a subform control, it loses its name.
Access often names the subform control (which is not often the name of
the form it contains) as child1 or somethoing similar.

You can check the .name property of the subform control that contains
your frmOvertime, and refer to that, or you can simply refer to
lngEmpl = me.Parent![txtEmpID].

Hope that helps.
 
Back
Top