referring to controls on a subform of a tabbed form

  • Thread starter Thread starter JulieD
  • Start date Start date
J

JulieD

hi

i've just checked out the article on Referring to Controls on a tabbed form
at www.mvps.org/access and still can't seem to get it to work.

i have a tabbed form (call FRM_Students), on the second tab of this form i
have a (continuous) subform called sFRM_Workplaces, and what i would like to
do is set the focus to a control (dateto) on this subform if an error occurs
(afterupdate event of the form)

the article says that the way to refer to a control on a tab page is
[subform control name].Form![control name]
which, if i'm understanding it correctly would translate to
sFRM_Workplaces.Form!dateto.setfocus

however, when i run the code i get the error message
"Variable not defined"
and sFRM_Workplaces highlighted.

Please help.

Regards
JulieD
 
Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
On the Other tab of the Properties box, what is the Name of the subform
control?

The subform control's Name may be different from its SourceObject (the name
of the form it contains).
 
Hi Allen

Thanks for your response
yes, it does have a different name jTBL_Workplaces
but when i change the code to that - so it now reads
jTBL_Workplaces.Form!dateto.setfocus

i still get the same error message

Regards
julieD

Allen Browne said:
Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
On the Other tab of the Properties box, what is the Name of the subform
control?

The subform control's Name may be different from its SourceObject (the name
of the form it contains).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JulieD said:
i've just checked out the article on Referring to Controls on a tabbed form
at www.mvps.org/access and still can't seem to get it to work.

i have a tabbed form (call FRM_Students), on the second tab of this form i
have a (continuous) subform called sFRM_Workplaces, and what i would
like
to
do is set the focus to a control (dateto) on this subform if an error occurs
(afterupdate event of the form)

the article says that the way to refer to a control on a tab page is
[subform control name].Form![control name]
which, if i'm understanding it correctly would translate to
sFRM_Workplaces.Form!dateto.setfocus

however, when i run the code i get the error message
"Variable not defined"
and sFRM_Workplaces highlighted.
 
Try setting focus to the subform control first:
Me.jTBL_Workplaces.SetFocus
Me.jTBL_Workplaces.Form!dateto.SetFocus
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JulieD said:
Hi Allen

Thanks for your response
yes, it does have a different name jTBL_Workplaces
but when i change the code to that - so it now reads
jTBL_Workplaces.Form!dateto.setfocus

i still get the same error message

Regards
julieD

Allen Browne said:
Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
On the Other tab of the Properties box, what is the Name of the subform
control?

The subform control's Name may be different from its SourceObject (the name
of the form it contains).
form
i
have a (continuous) subform called sFRM_Workplaces, and what i would
like
to
do is set the focus to a control (dateto) on this subform if an error occurs
(afterupdate event of the form)

the article says that the way to refer to a control on a tab page is
[subform control name].Form![control name]
which, if i'm understanding it correctly would translate to
sFRM_Workplaces.Form!dateto.setfocus

however, when i run the code i get the error message
"Variable not defined"
and sFRM_Workplaces highlighted.
 
Back
Top