Question : Refer to control on a subform inside a tab control

Hi all,

This issue has been raised by other users of this site, such as in this post: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_26322592.html?sfQueryTermInfo=1+10+30+control+refer+subform+tab

however, I have not been able to get any of the solutions to work for me. I have a subform inside a tab control. I want to write code so that after entering data in the last field on the first tab, the focus is set to the first field on the second tab, which is inside the subform. The names are as follows:

main form: IASForm
sub form: HHForm
last field on main form: consent
first field on sub form: respondent

I tried this:

Private Sub consent_AfterUpdate()
If Me.consent = "1" Then
Forms![IASForm]![HHForm].Form!respondent.SetFocus
Else
..other code...
End Sub

When I use this code, after consent is completed it just takes me back to the first field on the first tab of the tab control. Am I referring to the field inside the subform incorrectly?

J

Answer : Refer to control on a subform inside a tab control

Hi J

You must set focus first to the subform control on the main form, and then to the control within the subform.  Also, you should use "Me" to refer to the form which "owns" the code you are executing:

Me!HHForm.SetFocus
Me!HHForm.Form!respondent.SetFocus

Good luck!
--
Graham

Random Solutions  
 
programming4us programming4us