move to form from subform

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

Guest

How to I programmatically move the focus from a subform to the main form in
which it is embedded? It seems this should be so simple to accomplish, but I
can't seem to do it using either DoCmd.GoToControl or SetFocus.

Any help would be appreciated. Thank you,

Oli
04.11.06 08.04 hst
 
How to I programmatically move the focus from a subform to the main form in
which it is embedded? It seems this should be so simple to accomplish, but I
can't seem to do it using either DoCmd.GoToControl or SetFocus.

Any help would be appreciated. Thank you,

Oli
04.11.06 08.04 hst

Me.Parent!SomeControlName.SetFocus
 
Thanks for the suggestions, but I'm still getting an error: "[Application
title] can't move the focus to the control [control name]."

The code line reads:

Me.Parent!PCGrade.SetFocus

:
04.11.06 12.36 hst
 
Thanks for the suggestions, but I'm still getting an error: "[Application
title] can't move the focus to the control [control name]."

The code line reads:

Me.Parent!PCGrade.SetFocus

:
04.11.06 12.36 hst

I would strongly suggest that you include the relevant text of any
preceding message when replying.

If you cannot get code to work it is important that you let us know
which event you are using, as well as any other code in that event.

Your above code should work, for example, from the click event of a
command button, if you have a control named "PCGrade" on a main form
and the button is on a sub-form.
It will NOT work from the BeforeUpdate event of a control on the
sub-form. It will work from that control's AfterUpdate event.
 
I really appreciate your following up on this. Here are the details:

I'm testing a field called GrowerNo in the subform. If it is null, the
assumption is that the user is done adding records in the subform, so I would
like to move the focus to a control called PCGrade in the main form, where
further processing occurs. The test is run in the OnEnter event of the
control named FruitClassNo, which follows GrowerNo in tab order in the
subform (where GrowerNo is the first tab stop). Here is the relevant code:

Private Sub FruitClassNo_Enter()
Select Case IsNull(GrowerNo)
Case True
Me.Parent!PCGrade.SetFocus
Case Else
..
End Select
End Sub

The problem is triggered when the Case True statement is executed.

On the basis of your latest message, I've done more detailed troubleshooting
of the code in the subform's OnExit event, where there is quite a bit of
programming going on. As I make changes there and turn on and off specific
elements of code, I've been able to narrow my field of focus and am making
progress toward pinpointing the problem. Your comments have certainly been of
tremendous help.

Thank you again,
Oli
04.12.06 04.29 hst

fredg said:
Thanks for the suggestions, but I'm still getting an error: "[Application
title] can't move the focus to the control [control name]."

The code line reads:

Me.Parent!PCGrade.SetFocus

:
04.11.06 12.36 hst

I would strongly suggest that you include the relevant text of any
preceding message when replying.

If you cannot get code to work it is important that you let us know
which event you are using, as well as any other code in that event.

Your above code should work, for example, from the click event of a
command button, if you have a control named "PCGrade" on a main form
and the button is on a sub-form.
It will NOT work from the BeforeUpdate event of a control on the
sub-form. It will work from that control's AfterUpdate event.
 
Back
Top