Can't hide a control on a subform

  • Thread starter Thread starter Fred Parkinson
  • Start date Start date
F

Fred Parkinson

Why does Access insist i can't hide a control that has
the focus, when I specifically move the focus before
attempting to hide the control? The following is the
code that fails:

strSQL = "SELECT tcourses.a1required,
tcourses.a2required, ... FROM...etc."
Set rstCourses = CurrentDb.OpenRecordset(strSQL,
dbOpenDynaset)
rstCourses.MoveFirst

'in the following line I specifically move the focus to a
control that is not being hidden:
Me.txtDescription.SetFocus

' here I attempt to hide or reveal the controls (on a
subform) that are specific to the course record being
examined, but I immediately get the error "Can't hide a
control that has the focus":
Me![fRegDetailsSPMS]![chkA1Submitted].Visible =
rstCourses!a1required

Any ideas are greatly appreciated
Fred Parkinson
(e-mail address removed)
 
You need to go throught the subform's form object to get to its
controls. Like...

Me.fRegDetailsSPMS.Form!chkA1Submitted.Visible =

- Jim
 
My *guess* is that there are 2 distinct Foci involved
here: 1 Focus for the Main Form and 1 for the Subform.

It looks to me that you tried to move the (MainForm's)
Focus to a Control you think it is safe so that you can
hide a Control in the SubForm. It is likely that the
(Subform's) Focus is still on the Control you want to hide
and therefore you got the error msg.

Try moving the (Subform's) Focus to another Control *on
the Subform* before trying to hide the other Control.

HTH
Van T. Dinh
MVP (Access)
 
Eureka!
There must indeed be multiple 'foci' (why didn't I think
of that?).

I moved focus on the subform to an unaffected text box
and voila! Problem solved!
Thank you very much for responding to my question.

Fred Parkinson
-----Original Message-----
My *guess* is that there are 2 distinct Foci involved
here: 1 Focus for the Main Form and 1 for the Subform.

It looks to me that you tried to move the (MainForm's)
Focus to a Control you think it is safe so that you can
hide a Control in the SubForm. It is likely that the
(Subform's) Focus is still on the Control you want to hide
and therefore you got the error msg.

Try moving the (Subform's) Focus to another Control *on
the Subform* before trying to hide the other Control.

HTH
Van T. Dinh
MVP (Access)


-----Original Message-----
Why does Access insist i can't hide a control that has
the focus, when I specifically move the focus before
attempting to hide the control? The following is the
code that fails:

strSQL = "SELECT tcourses.a1required,
tcourses.a2required, ... FROM...etc."
Set rstCourses = CurrentDb.OpenRecordset(strSQL,
dbOpenDynaset)
rstCourses.MoveFirst

'in the following line I specifically move the focus to a
control that is not being hidden:
Me.txtDescription.SetFocus

' here I attempt to hide or reveal the controls (on a
subform) that are specific to the course record being
examined, but I immediately get the error "Can't hide a
control that has the focus":
Me![fRegDetailsSPMS]![chkA1Submitted].Visible =
rstCourses!a1required

Any ideas are greatly appreciated
Fred Parkinson
(e-mail address removed)

.
.
 
Back
Top