a little program to show what i mean.
run the program and click the form (the caption remains 1), click on Text2 to give it the focus, and click the form again (caption changes to 2)
then do the same while Text2.SetFocus is uncommented in Form_Click
here is the code :
'1 form with
' textbox : name=Text1 tabindex=0
' textbox : name=Text2 tabindex=1
Option Explicit
Private Sub Form_Click()
'uncomment the following line to make it work
' Text2.SetFocus
'with just the following call this wont work
Text1.SetFocus
End Sub
Private Sub Text1_GotFocus()
'increase the number in the form caption to show text1 got the focus again
Caption = CStr(Val(Caption) + 1)
End Sub
when the program starts Text1 gets the focus (tabindex=0), so the form caption changes to 1
when you click the form nothing changes because Text1 already has the focus and ddn't "get" it
when you first click on Text2 and then click the form the form caption increases
by uncommenting the line with Text2.SetFocus you let the program always move the focus to Text2 (if it's not already there), before moving the focus to Text1, so Text1 will always "get" the focus anew
be careful though! as giving the focus to another control first might spawn some new events which you might not want!