Vis/Invis SetFocus conundrum

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?
 
S

storrboy

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
 
G

Guest

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.
 

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

Similar Threads

set focus 2
Subform: record select form other subform 23
.Bookmark = .RecordsetClone.Bookmark 3
Subform goes blank 1
record vanishes on acNewRec 4
format combo box 6
setfocus from subfrom 8
SetFocus on a form 3

Top