Disable control on exit - Can't disable control that has focus...

J

JBHansen

This is just a minor question, but it's one that has me stumped:

I have a control that I would like to make invisible after the user leaves
it. However, I also know you can't disable a control when it has the focus,
so I can't use the OnExit or OnLostFocus events of this control. Is there a
simple way to do this --- or am I going to have to do it the hard way?

Here's the "hard way" that I've come up with so far: Code a visible=false
into the OnEnter event of all other controls on the form. That seems kind of
clunky, but I haven't come up with anything else that works.

Thanks in advance!
 
G

Greg Snidow

Greetings. This might work for you.Put an unbound text somewhere on the
form, say txtFocus. Make the back color the same as your form. Set its
height to .0007. Then try

Private Sub
YourControl_onLostFocus
me.txtFocus.setfocus
me.yourcontrol.visible=false
Exit sub.
I use this for command buttons to disable controls, but I am not sure how a
lostfocus event behaves.
 

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

Top