How detect when mouse moves out of a textbox ???

D

David

I have a text box that must have a non-blank value before a button can be enabled

I'm using the 'on lostfocus' event but that does not trigger until I click someplace else
I want the button to enable immediately the mouse moves out of the textbox provided the contents are non blank

Is there any way
 
D

Dirk Goldgar

David said:
I have a text box that must have a non-blank value before a button
can be enabled.

I'm using the 'on lostfocus' event but that does not trigger until I
click someplace else.
I want the button to enable immediately the mouse moves out of the
textbox provided the contents are non blank.

Is there any way?

Theoretically, I guess, you could use the MouseMove event of the section
(Detail, Form Header, Form Footer) that contains the text box. But it
seems to me that it would make a lot more sense to use the AfterUpdate
event of the text box to determine whether the text box is now nonblank.
Of course, you'd have to have code in some preliminary event to
determine whether the control is initially blank and enable or disable
the button accordingly. That could be the form's Current event, or
maybe the control's Enter or GotFocus event.
 
H

hajksmnrtltabnwolkst

Thanks for the reply. I have tried the 'lostfocus', 'exit' and 'after update' events and all require me to click someplace else to activate.
 
K

Ken Snell

Not really. After you enter the value in the textbox, just press Tab or
Enter. Your AfterUpdate code will run, and if valid, the command button will
be made visible. Even if the button is next in the Tab order, the focus then
will move to the now visible button.

I concur with Dirk. I always use the AfterUpdate event for what you seek to
do.

--

Ken Snell
<MS ACCESS MVP>

hajksmnrtltabnwolkst said:
Thanks for the reply. I have tried the 'lostfocus', 'exit' and 'after
update' events and all require me to click someplace else to activate.
 
D

Dirk Goldgar

"hajksmnrtltabnwolkst" <[email protected]>
wrote in message
Thanks for the reply. I have tried the 'lostfocus', 'exit' and 'after
update' events and all require me to click someplace else to
activate.

But (a) what makes you think the user will use the mouse instead of the
keyboard to cause the focus to leave the control, and (b) what if the
user intends to use the mouse to do something on the menubar or toolbar,
or to work outside the application entirely?

I suppose you could use the Change event of the text box and test in
that event to see if the control's Text property has zero length. That
way you could enable or disable the button the instant the user begins
to change the text in the control.
 

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