Setting Focus on a Form with a SubForm

I'm having difficulty setting focus to a field on the subform. Here's the picture. On the search form I enter a claim number it then searches the the database to retrieve the individual associated with that claim if found it will bring up the history screen with the individuals name and address. On the form that it brings up will be a subform to enter the the date and other information. I want the focus to transfer to the date on the subform. Help.
Who is Participating?
thenelsonConnect With a Mentor Commented:
I know you already got the answer.  Here is more info:

The form/subform (everything discussed here applies to a report/subreport also) confuses a lot of programmers. The concept of a subform is actually a misnomer. There really is not a thing called a subform. What we really have is a form contained within another form. There are three objects, the two forms and a subform container that holds the form within. To better illustrate this, it is actually possible to have a second copy of the main form in the subform container. The three objects each have a name. The subform container and the form within the container can share the same name (although for less confusion, it it better they do not have the same name.) The subform container has the link master and link child field properties that connect the two forms together.  Although the form within the container is just a form, we call it a subform.

When we first click on a subform, the subform container is highlighted. This is indicated by the appearance of the eight sizing handles on the subform container frame. The second time we click on the subform, the form within is highlighted indicated by the small square dot appearing in the upper, left corner of the form. The third time we click on a subform, a control within the form will be highlighted.

When you have nested subforms, this is repeated:
Main form
   Subform container within the main form
      Form within the subform container
         Subform container within the form (subform)
            Form within the nested subform container

To set focus on a control in the subform, we first have to set focus on the subform container:

It you are in the main form, you can replace
with the Me keyword:

A subform container nested within a subform is a control in the subform so you would set focus to it just like any other control in the subform. To set focus on a control in a nested subform, we have to drill down to it:

We perform an action on or set the property of a subform container:
Forms!MainFormName!SubformContainerName.Visible = True

On a nested subform:
Forms!MainFormName!SubformContainerName!Sub-SubformContainerName.Visible = True
You need 2 lines and the syntax should look like :

RJWAGNERAuthor Commented:
Where and on which forms should these lines be add too.
Many possibles places...  depending on when you want the focus to move there...

You say you bring up a form...  One place for the code (if the form is not modal) could be right after that :

'I guess you have a docmd.openform somewhere...

Docmd.openform "MyFormName"...
Glad to help and thank you very much for the points with "A" grade but didn't jmantha709 give you the correct answer first?  Shouldn't he get at least a share?

Happy Computing!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.