I am using VB6 and Access. i have several text boxes arranged on a form. what is want is that when the focus is in a certain text box and the user presses the up arrow key, the focus goes to the text box before it. How can this be done??? Is there any way in which i can connect all textboxes like a linked list and shift the focus to previous text box on up arrow key press???? or any other way to achieve the same???
Up Arrow Key
Collapse
X
-
Originally posted by mcluelessI am using VB6 and Access. i have several text boxes arranged on a form. what is want is that when the focus is in a certain text box and the user presses the up arrow key, the focus goes to the text box before it. How can this be done??? Is there any way in which i can connect all textboxes like a linked list and shift the focus to previous text box on up arrow key press???? or any other way to achieve the same??? -
Originally posted by daniel aristidouYou can use tab to change which textbox has focus.....
But tab helps the focus to shift on a control with a higher tabindex property. what if i want to go back to some textbox where i already have been but want to go again for some modifications. What we normally do is take the mouse pointer to that text box and click but i want to allow this using keyboardComment
-
This works for textbox Text1(0 to X)
Code:Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) Static Choose As Integer If KeyCode = vbKeyDown Then Choose = Index + 1 If Choose >= Text1.Count Then Choose = 0 Text1(Choose).SetFocus ElseIf KeyCode = vbKeyUp Then Choose = Index - 1 If Choose < 0 Then Choose = Text1.Count - 1 Text1(Choose).SetFocus End If End Sub
Comment
-
Nice one Dawoodoz. I suppose you could also try simulating a Tab or BackTab keypress, but your technique is probably cleaner and more reliable.
One thing - I hope these are single-line textboxes, or you may confuse the user.
Another point - mclueless, have you considered using some type of grid control instead of textboxes?Comment
-
hi
add following code to keydown event of every text box (if you are not using index array)
[CODE=vb]Private Sub Text1_KeyDown(K eyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then
SendKeys "{TAB}"
ElseIf KeyCode = vbKeyUp Then
SendKeys "+({TAB})"
End If
End Sub[/CODE]
regards
manpreet singh dhillon hoshiarpurComment
Comment