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

G

Guest

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

Guest

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.
 
G

Guest

Thanks Greg. We'll give that a try. I'm wondering, though - won't the user
then have to click on their intended destination field, since the focus will
go to txtFocus when they leave? So if they hit the tab button to leave the
initial control, or click on another control and the focus goes to txtFocus,
it might be a little distracting since they expected the cursor to go
somewhere else.

At any rate, we'll see how this works and adjust if necessary.

Thanks again.
 

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