Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

allow tab key in select case for ascii vba

Posted on 2016-09-16
2
Medium Priority
?
68 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 40

Accepted Solution

by:
PatHartman earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

916 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