By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

Up Arrow Key

P: 56
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???
Feb 3 '08 #1
Share this Question
Share on Google+
5 Replies


daniel aristidou
100+
P: 491
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???
You can use tab to change which textbox has focus.....
Feb 3 '08 #2

P: 56
You 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 keyboard
Feb 3 '08 #3

P: 14
This works for textbox Text1(0 to X)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
  2.     Static Choose As Integer
  3.     If KeyCode = vbKeyDown Then
  4.         Choose = Index + 1
  5.         If Choose >= Text1.Count Then Choose = 0
  6.         Text1(Choose).SetFocus
  7.     ElseIf KeyCode = vbKeyUp Then
  8.         Choose = Index - 1
  9.         If Choose < 0 Then Choose = Text1.Count - 1
  10.         Text1(Choose).SetFocus
  11.     End If
  12. End Sub
  13.  
Feb 3 '08 #4

Expert 5K+
P: 8,434
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?
Feb 4 '08 #5

9815402440
100+
P: 180
hi
add following code to keydown event of every text box (if you are not using index array)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
  2.     If KeyCode = vbKeyDown Then
  3.         SendKeys "{TAB}"
  4.     ElseIf KeyCode = vbKeyUp Then
  5.         SendKeys "+({TAB})"
  6.     End If
  7. End Sub

regards
manpreet singh dhillon hoshiarpur
Feb 7 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.