Unable to set focus to a control in sub-form

A

Amit

Hi,

I have a form which includes a sub-form. What I'm trying
to accomplish is that when a user is entering data on the
form and moves from one control to the next using TAB,
s/he is able to move to the first control on the sub-form
from the last control on the main-form.

To accomplish this, I added an unbound text-box control on
the main form, and in the "Got Focus" property of the
control, I added the following code:

=========================================================
Private Sub txtTabToDate_GotFocus()
'move focus to the date field in the sub-form
Me!sfrmPerson.Form!SurveyCompletedDate.SetFocus
End Sub
=========================================================

What happens is that as soon as I tab into the unbound
text control, the cursor stays there, and moves to the
desired control only when I press TAB another time.

I guess the problem is how I'm referencing the control on
the sub-form from the main-form. I thought I had it right,
but I guess not.

Any help on the correct reference (assuming that's the
problem here) in the above code will be much appreciated.

The name of the sub-form control on the main-form
is "sfrmPerson", and the control I'd like to move to
is "SurveyCompletedDate".

Thanks!

-Amit
 
M

Marshall Barton

Amit said:
I have a form which includes a sub-form. What I'm trying
to accomplish is that when a user is entering data on the
form and moves from one control to the next using TAB,
s/he is able to move to the first control on the sub-form
from the last control on the main-form.

To accomplish this, I added an unbound text-box control on
the main form, and in the "Got Focus" property of the
control, I added the following code:

=========================================================
Private Sub txtTabToDate_GotFocus()
'move focus to the date field in the sub-form
Me!sfrmPerson.Form!SurveyCompletedDate.SetFocus
End Sub


First set the focus to the subform control:

Private Sub txtTabToDate_GotFocus()
'move fuce to subform control
Me!sfrmPerson.SetFocus
'move focus to the date field in the sub-form
Me!sfrmPerson.Form!SurveyCompletedDate.SetFocus
End Sub
 

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