Referencing a subform contral

  • Thread starter gsnidow via AccessMonster.com
  • Start date
G

gsnidow via AccessMonster.com

Greetings all. I have read many post regarding this topic, but I still can
not get it to work. In Access 2002 I have the following:

Main form: frmFieldPM_Filter
Subform: Child1
Subform source object: frmFieldPM_Sub
Subform control: txtCO

I have three cascading combos on the main form, frmFieldPM_Filter, with an
after update event on the last one that requeries the sub. I would like to
also set focus to the first control on the sub after the requery. The
requery works with:

Forms!frmFieldPM_Filter.Child1.Requery

I can not get the set focus to work. I have tried many, but this is what I
last tried. I get an error saying the database can't find the form
referenced in the query.

Forms!frmFieldPM_Filter!frmFieldPM_Sub.Form!txtCO.SetFocus

Part of my confusion is that I am not sure if I am supposed to be referencing
the control name, Child1, or the control's source object, frmFieldPM_Sub.
Thank you for the time.
 
M

Marshall Barton

gsnidow said:
Greetings all. I have read many post regarding this topic, but I still can
not get it to work. In Access 2002 I have the following:

Main form: frmFieldPM_Filter
Subform: Child1
Subform source object: frmFieldPM_Sub
Subform control: txtCO

I have three cascading combos on the main form, frmFieldPM_Filter, with an
after update event on the last one that requeries the sub. I would like to
also set focus to the first control on the sub after the requery. The
requery works with:

Forms!frmFieldPM_Filter.Child1.Requery

I can not get the set focus to work. I have tried many, but this is what I
last tried. I get an error saying the database can't find the form
referenced in the query.

Forms!frmFieldPM_Filter!frmFieldPM_Sub.Form!txtCO.SetFocus

Part of my confusion is that I am not sure if I am supposed to be referencing
the control name, Child1, or the control's source object, frmFieldPM_Sub.


You got the part about referencing the subform control
right. Somewhere in the last few versions of Access, they
made using the .Form property mandatory.

Another point is that the focus needs to go to the subform
control before going to the control in the subform.

Me.Child1.Form.Requery
Me.frmFieldPM_Sub.SetFocus
Me.frmFieldPM_Sub.Form!txtCO.SetFocus
 
G

gsnidow via AccessMonster.com

Thanks Marshall. That worked. Sorry for the late feedback.

Greg

Marshall said:
Greetings all. I have read many post regarding this topic, but I still can
not get it to work. In Access 2002 I have the following:
[quoted text clipped - 19 lines]
Part of my confusion is that I am not sure if I am supposed to be referencing
the control name, Child1, or the control's source object, frmFieldPM_Sub.

You got the part about referencing the subform control
right. Somewhere in the last few versions of Access, they
made using the .Form property mandatory.

Another point is that the focus needs to go to the subform
control before going to the control in the subform.

Me.Child1.Form.Requery
Me.frmFieldPM_Sub.SetFocus
Me.frmFieldPM_Sub.Form!txtCO.SetFocus
 
M

Marshall Barton

gsnidow said:
Thanks Marshall. That worked. Sorry for the late feedback.


Not a problem for me, the important point is to have a
record of success in the Google archives when others are
searching for answers to the same problem in the future.

On the other hand, it's nice to know that I was able to help
you move your project forward. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top