Vis/Invis SetFocus conundrum

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

Guest

My main form [frm1 Client] has a subform [Jobfrm] which has a subform
[Laborfrm].

After the following code worked forever, I now get the can't hide focused
form message. The code is a click event on a button on the [Laborfrm] and
intended to hide it.

The code:
Forms![frm1 Client].Form![HoldFocus].SetFocus
Forms![frm1 Client].Form![Jobfrm].Form![Laborfrm].Visible = False
(also used me.visible=false)

Until this morning the code worked. I am working on [Laborfrm] but cannot
see what I have done that would cause this. It seems simple code and DID
work; why not now?

I have tried recreating the dbase clean as if it were corrupted, linking
tables and importing the rest, but the problem remains.

Can anyone help, please?
 
I honestly don't see why it would have worked before. From what I can
tell the syntax should be...

Forms![frm1 Client]![HoldFocus].SetFocus
Forms![frm1 Client]!SUBFORMCONTROLNAME. _
2ndSUBFORMCONTROLNAME.Form.Visible = False

Or since it's running from the lowest subform, you could try

Me.Parent.Parent![HoldFocus].SetFocus
Me.Visible = False

But now that I think about it, you may have to make the SubFormControl
itself not visible, not the form - or set the controls SourceObject to
an empty string.

Me.Parent.Parent![HoldFocus].SetFocus
Me.Parent.SUBFORMCONTROLNAME.Visible = False
 
Thanks for responding.

This worked.
Me.Parent!txtholdFocus.SetFocus
Me.Visible = False
([holdfocus] is on mainform; [txtholdfocus] is on 1st subform.

Thanks for the insight...now I am ok again.

Your suggestions yielded...
1.
Forms![frm1 Client]![HoldFocus].SetFocus
Forms![frm1 Client]![Jobfrm].[Laborfrm].Form.Visible = False

Object doesn't support this property or method.

2.
Me.Parent.Parent![HoldFocus].SetFocus
Me.Visible = False

Can't hide a control that has the focus.

3.
Me.Parent.Parent![HoldFocus].SetFocus
Me.Parent.Laborfrm.Visible = False

Can't hide a control that has the focus.
 
Back
Top