RoyLiam
01-04-2007, 07:20 PM
Hi
I have a user form that allows the user to input five client codes in consecutive text boxes, called code1, code2 etc. to code5, and then there is a button 'GetClient' that retreives information for those clients.
What I would like to do is on the exit of a text box, test to see whether a code has been entered by the user. If not, then I would like the 'active' box to jump to the GetClient control that is set in the tab order for the form to take focus after the text boxes, This would save the user have to press tab repeatedly when only inputting say one client.
I have tried the following
Private Sub code2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If code2.Text = "" Then GetClient.SetFocus
End Sub
which strangely makes the active cell jump the next control in the tab order, code3, and land on code 4, rather than jumping to the GetClient control
I have also tried
Private Sub code2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If code2.Text = "" Then GetClient.TabIndex = 2
End Sub
which doesn't seem to catch the tab order immediately; the focus goes to the next in the tab order, code3, rather than the GetClient control. If you jump back up to code1 and tab through again, it does function correctly, jumping to GetClient after code2 though it seems that you can't set something to the next in the tab order on the exit of the control before.
Any ideas or suggestions would be most welcome.
Thanks
Liam
I have a user form that allows the user to input five client codes in consecutive text boxes, called code1, code2 etc. to code5, and then there is a button 'GetClient' that retreives information for those clients.
What I would like to do is on the exit of a text box, test to see whether a code has been entered by the user. If not, then I would like the 'active' box to jump to the GetClient control that is set in the tab order for the form to take focus after the text boxes, This would save the user have to press tab repeatedly when only inputting say one client.
I have tried the following
Private Sub code2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If code2.Text = "" Then GetClient.SetFocus
End Sub
which strangely makes the active cell jump the next control in the tab order, code3, and land on code 4, rather than jumping to the GetClient control
I have also tried
Private Sub code2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If code2.Text = "" Then GetClient.TabIndex = 2
End Sub
which doesn't seem to catch the tab order immediately; the focus goes to the next in the tab order, code3, rather than the GetClient control. If you jump back up to code1 and tab through again, it does function correctly, jumping to GetClient after code2 though it seems that you can't set something to the next in the tab order on the exit of the control before.
Any ideas or suggestions would be most welcome.
Thanks
Liam