SetFocus

  • Thread starter Thread starter Tarek
  • Start date Start date
T

Tarek

Hello!
is it possible to know if a control has the focus or not?
because I need to hide a textbox, however, if this one has the focus, Access
cannot hide it
so I'm obliged to give the focus to another control before hiding it.. is it
possible to hide without setting the focus to something else?

Thanks for any suggestion
 
Thanks for your answer!

ok, so is it possible to remove the focus from the control wihtout giving it
to another control??

Thanks again for any suggestions
 
As far as I know you cant remove the focus unless you specifye where to set
focus!

What you can do is to put following code in the control´s Enter_event (the
control you want to hide).
=================================================
' First you set focus to another control.
Me.NameOfOneControlThatYouMoveFocusTo.SetFocus

' Then you set visible property for the control to false.
Me.NameOnTheControlYouWantToHide.Visible = False
=================================================

// Niklas
 
When I find Focus issues like yours frustrating I create a "DummyFocus"
control (usually a text box), set its size to zeros, disable tabbing to it,
data lock it and tuck it away on an obscure part of the form. When I need to
move the focus temporarily (e.g. skipping the focus away from one control
and back again) I use this DummyFocus control. Clunky, but it works.

HTH

WSF
 
Back
Top