Solved

Capture Key Codes within a Text Box

Posted on 2006-12-01
3
728 Views
Last Modified: 2008-03-03
I'm trying to capture certain key strokes within an Access application.  I've been using this function:


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

    Select Case KeyCode
      Case vbKeyDelete
        'User pressed the Delete key
    End Select

  End Sub


However, this only seems to work when they are not inside of a text box.  I'm looking to capture these key strokes when they are  entering data into a text box.  Is this possible?  Thanks in advance for your help.

0
Comment
Question by:cfg1980
[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
  • 2
3 Comments
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18056347
Here's something close

Dim WholeString As String
Dim LengthString As Long
-----------------------------------------
Private Sub data1_Change()
Dim myStr As String
Dim strPos As Long
strPos = Len(Me.data1.Value)
myStr = Right(Me.data1.Value, strPos - LengthString)
WholeString = WholeString & myStr
LengthString = strPos
End Sub
----------------------------------------
Private Sub data1_GotFocus()
WholeString = ""
LengthString = 0
End Sub
----------------------------------------
Private Sub data1_LostFocus()
MsgBox WholeString
End Sub
0
 
LVL 34

Accepted Solution

by:
jefftwilley earned 125 total points
ID: 18056399
This one works too

Private Sub data1_KeyDown(KeyCode As Integer, Shift As Integer) ' Where Data1 is the name of your textbox
 Select Case KeyCode
      Case vbKeyDelete
        MsgBox "User pressed the Delete key"
    End Select

End Sub
0
 

Author Comment

by:cfg1980
ID: 18056485
That was exactly what I was looking for....thank you!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

739 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