?
Solved

Form_Keydown not allowed Tab Key

Posted on 2006-06-22
5
Medium Priority
?
171 Views
Last Modified: 2010-04-07
I have a richtextbox and i need to use the tab key to move the text in the box and ive figured out it has something to do with this. How can i allow the tab key be passed through....

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

    Case 112
        txtUDS.Locked = False
        lblStatus.Caption = "Writable"
    Case 115
        'Run Code
       
    Case 121
        Unload Me
    Case Else
        MsgBox KeyCode
End Select

End Sub

Private Sub Form_Load()
Me.KeyPreview = True
End Sub
0
Comment
Question by:thaburner
[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
  • 3
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
Sethi earned 800 total points
ID: 16965909
Private Sub richClinicalNotes_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyTab Then
        KeyCode = 0
        richClinicalNotes.SelText = vbTab
    End If
End Sub
0
 

Author Comment

by:thaburner
ID: 16969722
hmmm didnt work
0
 
LVL 18

Expert Comment

by:Sethi
ID: 16969837
You want the tab key to work in the richtextbox instead of navigating out? If yes then it has to work as I have been using this code for many years in my projects. Please change the name of the richtextbox in the code.
0
 

Author Comment

by:thaburner
ID: 16971526
i got it working with your code provided i just had to turn the TabStop=False
Thx
0
 
LVL 18

Expert Comment

by:Sethi
ID: 16973599
I am not sure why you had to turn TabStop=False as that is not required.
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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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, 19 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