Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test for ENTER keypress out of a text box

Status
Not open for further replies.

DaveTappenden

Programmer
Jan 16, 2002
21
0
0
I have set up Access Database options so that ENTER takes the user to the next field in the form. This is my preferred default. However, on occasions I need to determine if the user has pressed the ENTER key to exit the text box as opposed to say a TAB or DOWN ARROW.
Can anyone assist me with the procedure to test for what key has been pressed on exiting from the control?

Thanks.
 
In the control's On_Enter event set the FORM's KeyPreview property to Yes

Then in the FORM's On_KeyPress event, for each keystroke that the control received test for {Enter}, {Tab} etc and react accordingly.

In the Control's On_Exit don't forget to set the FROM's KeyPreview property to No


'ope-that-'elps.

G LS
 
Thanks LittleSmudge but...
I can trap all key presses with the onkeypress except ENTER or TAB which are the keys I need to trap.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top