PC Review


Reply
Thread Tools Rate Thread

Capturing Enter key press inconsistent behaviour

 
 
andy.cotgreave@gmail.com
Guest
Posts: n/a
 
      14th Jul 2006
HI,
I have a form with various text boxes and buttons.

One button is the Default, so any "Enter" key presses trigger that
button's Click event.

I added a new text box and a new button. For this text box, when the
user presses Enter, the NEW button's click event must be triggered.

I trap the Enter key in the KeyDown event of the new text box, looking
for a keycode of 13.

Here's the problem:
- If i put a breakpoint in the code, the Enter key is trapped and the
correct button's click event is called
- if i tab into the new text box from another text box and immediately
press enter, it works correctly.
- if i TYPE something in the new text box and THEN press enter, the
default action is triggered, and my Enter key handling doesn't work.

Any ideas?

(running Access 2003)
Andy

 
Reply With Quote
 
 
 
 
Albert D.Kallal
Guest
Posts: n/a
 
      14th Jul 2006
You likely are not throwing out the keypress.....

Access is being confused, since you have Enter key = default for a
particular button....

In anther case...you want to do something else...

Add the following line of code

keypress = 0 ' throw keypress into black hole...access will not see
it...

Hence,your you code would (something) like

Private Sub Text28_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 13 Then

KeyCode = 0 ' black hold for key...

Call Command30_Click
End If

End Sub

By adding the keycode = 13, then the standard default button, or anything
else for that matter will NOT see/get/use the keypress....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)
http://www.members.shaw.ca/AlbertKallal


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why does enter symbol appear when i press enter key =?Utf-8?B?bWVldGJlY2s=?= Microsoft Word Document Management 2 23rd Aug 2006 12:44 PM
Enter user name, enter password, then press enter... =?Utf-8?B?UGF1bCAoRVNJKQ==?= Microsoft Access Forms 6 11th Jul 2005 05:41 PM
Capturing the TAB key press in the DataGrid =?Utf-8?B?VmVudUdvcGFs?= Microsoft C# .NET 0 19th Apr 2005 01:01 PM
Capturing a TAB key press event supster Microsoft C# .NET 7 29th Mar 2005 02:36 AM
frezes at setup will now install windows-press enter to continue/press R to repa Ric Windows XP Setup 0 15th Oct 2003 06:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:36 AM.