A 'GoToControl' question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Any help is greatly appreciated.

I'm creating a lengthy data entry form for the purpose of entering a
four-page contract. There are many tables involved in this form. I'm
setting the form up with steps for the user to follow to go from one segment
to the next. So in instances where the user is entering in a subform, when
they reach the last field in the subform I have a 'OnLostFocus' event that
says

DoCmd.GoToControl "Control"

This works fine to take a user from a subform back to a field in the parent
form. However, when taking a user from a subform in a subform, back to the
first subform or the parent form, I get a Run-time error '2109'. I just need
the correct syntaxt to make it work two layers deep?
 
Glenn said:
I'm creating a lengthy data entry form for the purpose of entering a
four-page contract. There are many tables involved in this form. I'm
setting the form up with steps for the user to follow to go from one segment
to the next. So in instances where the user is entering in a subform, when
they reach the last field in the subform I have a 'OnLostFocus' event that
says

DoCmd.GoToControl "Control"

This works fine to take a user from a subform back to a field in the parent
form. However, when taking a user from a subform in a subform, back to the
first subform or the parent form, I get a Run-time error '2109'. I just need
the correct syntaxt to make it work two layers deep?


Not sure I followed all that, but I can for sure tell you to
replace the GoToControl with SetFocus.

From a subform to its parent form:
Me.Parent.controlname.SetFocus

From one subform on the main form to a different subform on
the main form:
Me.Parent.othersubform.SetFocus
Me.Parent.othersubformForm.controlname.SetFocus
 
This didn't work. Could it be that I'm working with Access version 2000?

When I type Me. Access prompts me for a command instead of a form/field name.

Do you have another suggestion?
 
No, I don't have another suggestion, but maybe we can figure
out why this one didn't work.

You say you got something funny when you typed Me? This is
probably because you put the statements in the wrong place.
Maybe you place it after DoCmd or in a macro?? More details
are needed before I can figure out what's wrong.
 
Glenn said:
This didn't work. Could it be that I'm working with Access version 2000?

When I type Me. Access prompts me for a command instead of a form/field name.

Do you have another suggestion?


A little too quick on the send button.

I meant to add that the SetFocus stuff should be in the
control's Exit event procedure.
 
I just got it to work. I left off the Me. and entered

Forms!ParentFormName!SubFormName!ControlName.SetFocus

And that worked.

Thank you,

Marshall Barton said:
No, I don't have another suggestion, but maybe we can figure
out why this one didn't work.

You say you got something funny when you typed Me? This is
probably because you put the statements in the wrong place.
Maybe you place it after DoCmd or in a macro?? More details
are needed before I can figure out what's wrong.
--
Marsh
MVP [MS Access]
This didn't work. Could it be that I'm working with Access version 2000?

When I type Me. Access prompts me for a command instead of a form/field name.

Do you have another suggestion?
 
Back
Top