-
I have a text box that I don't want people to be able to tab out of. In the KeyPress event, I already tried this code:
If KeyAscii = vbKeyTab Then KeyAscii = 0
But it didn't work. It still tabs out of the textbox. I also tried:
If KeyAscii = vbKeyTab Then
KeyAscii = 0
Cancel = 1
End If
And
If KeyAscii = vbKeyTab Then
KeyAscii = 0
txtedit.SetFocus
End If
But that didn't work either. Any suggestions on how to keep it from tabbing out of the textbox?
------------------
Ryan
-
Try it in the keydown event or Keyup event
-
No, that didn't work. I think it's because in the KeyDown and KeyUp events the KeyAscii doesn't work.
------------------
Ryan
-
First of all, in the KeyDown and KeyUp command you have Keycode insted of the KeyAscii.
Second, It still won't do what you want it to do... I really don't remember the way to do what you want but you can try setting all the "Tabstop" values to false...
If you don't get a better reply I'll try finding the easier way to do it :)
-
I can't set all the TabStop values to 0 because I still need to be able to tab to the other textboxes, but just not from this textbox.
------------------
Ryan
-
What The_Inspector suggested is really your only solution, here's an example of how to implement it easily without loosing all Tab Functionality:
Code:
Private Sub Text1_GotFocus()
EnableTabs False
End Sub
Private Sub Text1_LostFocus()
EnableTabs
End Sub
Private Sub EnableTabs(Optional ByVal EnabledThem As Boolean = True)
On Error Resume Next
Dim oControl As Control
For Each oControl In Controls
oControl.TabStop = EnabledThem
Next
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
-
ok, yeah, now I see how I can apply what The_Inspector said. Thanks for your help, both of you.
------------------
Ryan