Solved

allow tab key in select case for ascii vba

Posted on 2016-09-16
2
37 Views
Last Modified: 2016-09-16
i'm having an issue that when a person presses a  <tab> key going from textbox to textbox,

The code below is firing off in the next textbox in the tab order. even though I have not pressed keys in that next textbox yet  ?

The event i have it on is..
Private Sub QUOTE_GP_KeyPress(KeyAscii As Integer)

Select Case True 'always your best friend
    Case (KeyAscii > 47 And KeyAscii < 58)
    Case (KeyAscii = 8)
    Case (KeyAscii = 43)
    Case (KeyAscii = 45)
    Case (KeyAscii = 46)
    Case Else
      '  MsgBox ("quote gp You Must Enter Numbers Only!")
        KeyAscii = 0
        Exit Sub
End Select

Open in new window

0
Comment
Question by:fordraiders
2 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 41801848
That actually makes sense.  The tab key is being passed to the control that has the focus.  I find the keypress event to be more trouble than it is worth and it is not the appropriate event for your purpose anyway.

If you want to trap each key as it is typed into a control, use the control's On Change event.
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 41802112
THNX
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

939 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

Need Help in Real-Time?

Connect with top rated Experts

3 Experts available now in Live!

Get 1:1 Help Now