Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Form_Keydown not allowed Tab Key

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
thaburner
Asked:
thaburner
  • 3
  • 2
1 Solution
 
SethiCommented:
Private Sub richClinicalNotes_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyTab Then
        KeyCode = 0
        richClinicalNotes.SelText = vbTab
    End If
End Sub
0
 
thaburnerAuthor Commented:
hmmm didnt work
0
 
SethiCommented:
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
 
thaburnerAuthor Commented:
i got it working with your code provided i just had to turn the TabStop=False
Thx
0
 
SethiCommented:
I am not sure why you had to turn TabStop=False as that is not required.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now