?
Solved

The keyPress event  of a textbox not triggered when hit the TabKey

Posted on 2003-04-01
6
Medium Priority
?
345 Views
Last Modified: 2013-12-26
I want to type something in the textbox and hit the return key or tab key, then some action happen.
The return key works fine, but not with the tab key. Can you tell me why?


Private Sub txtFind_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn or KeyAscii = vbKeyTab Then
        sscmdFind.DoClick
     End If
     
End Sub
0
Comment
Question by:huhu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Expert Comment

by:simon780
ID: 8246096
It worked for me!!
0
 

Expert Comment

by:simon780
ID: 8246111
If it doesn't try "KeyAscii = 9" instead of "vbKeyTab"

Are you sure the textbox's name is txtFind????
0
 
LVL 11

Expert Comment

by:supunr
ID: 8249908
tab key does not trigger keypress event.  to do that you have to use KeyUp event.

Private sub text1_keyup(Keycode as integer, ...)
    if (Keycode = vbkeytab) then
       ' your code
    end if
End sub

' Good Luck!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
y2ksw earned 150 total points
ID: 8261160
vbkeytab refers to your keyboard's scancode. It might be different on different keyboards. KeyAscii = 9 would be the right choice. For the rest, supunr is right.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9053323
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in a week or two.  I would appreciate any comments by the experts that would help me in making a recommendation.

It is assumed that any participant not responding to this request is no longer interested in its final deposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9117969
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept y2ksw's comment as Answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question