Use the Enter key for a Text Box?

D

Dan Williams

Is there a trick to allowing the user to type something in a text box,
and then press the Enter key to start an Event process?

If I use Sub textbox_Enter(), it works, but then just clicking in the
textbox executes that code, too (for some reason), when I don't want
it to.

I've heard that you should use _ AfterUpdate() instead, but then Enter
doesn't work if the user leaves the default text in the box.

I guess I could live with that, but another problem with the After
Update Event is that if you come back from choosing the text from a
dialog box (Open File), it executes the code without letting you look
at the text to confirm, before pressing Enter.

There must be some reasonable approach that everyone uses...?

Dan Williams
danwPlanet

P.S. I do also have a "Go" command button, and if the user presses
Enter twice, the focus goes there and it executes, but it would be
nice to let the user just press Enter once, which is more intuitive.
 
R

ruralguy via AccessMonster.com

The Exit and the LostFocus events fire every time you leave the control
whether it has changed or not.
 
K

Klatuu

I've heard that you should use _ AfterUpdate() instead, but then Enter
doesn't work if the user leaves the default text in the box.

True, but you can use the Form Before Update event to check for a correct
value. The event can be canceled.


I guess I could live with that, but another problem with the After
Update Event is that if you come back from choosing the text from a
dialog box (Open File), it executes the code without letting you look
at the text to confirm, before pressing Enter.

No, the only way the AfterUpdate fires is when a value is typed in by the
user.
 
D

Dan Williams

I've heard that you should use _ AfterUpdate() instead, but then Enter
doesn't work if the user leaves the default text in the box.

True, but you can use the Form Before Update event to check for a correct
value.  The event can be canceled.

I guess I could live with that, but another problem with the After
Update Event is that if you come back from choosing the text from a
dialog box (Open File), it executes the code without letting you look
at the text to confirm, before pressing Enter.

No, the only way the AfterUpdate fires is when a value is typed in by the
user.

--
Dave Hargis, Microsoft Access MVP











- Show quoted text -

No, that's incorrect.

I thought maybe it was happening because it was using the non-
recommended dlgMoreFile, from reference "Micosoft Common Dialog
Control", but I have now switched to Ken Getz's API code for selecting
a file, and the same thing still happens: _ AfterUpdate() gets
executed every time I return from the dialog box, even though Enter
was not pressed.

(This is Access 2000, Windows 2000.)

Dan
 

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