>>>>>lnMin = 9999
>>>>>
>>>>>FOR lnI = 1 TO _Screen.ActiveForm.ControlCount
>>>>> IF _Screen.ActiveControl.TabIndex < lnMin
>>>>> lnMin = _Screen.ActiveControl.TabIndex
>>>>> loControl = _Screen.ActiveControl
>>>>> ENDIF
>>>>>ENDFOR
>>>>>
>>>>>loControl.SetFocus()
>>>>
[snip, snip]
>>3. Are you sure you'll always have a TabIndex = 1?
>>
>>Vlad
>
>Yeah, I'm pretty sure that the control with TabIndex=1 will always be the
>one I want. I always have to go in and set the tab order anyway so I just
>set the field I want to TabIndex=1.
This has been discussed several months ago. It was suggested that the
finding of the first active control should go to form.init (unless you
intend to play with changing tab order at runtime, which is unlikely to
make users happy), and have a form property memorizing the control's
index (in the form.controls[i] array). This way it's done only once. I
am doing another thing - I have an array property on the form containing
focusable controls (i.e. their indexes) sorted by their tab indexes, and
assign the index into this array as an additional property to all the
controls (all in the form.init), so it's quite easy then to know a
control's next and previous neighbour as ordered by tabindex.
This kind of index juggling is a bit harder to implement, but it's safer
than making object references, which are hard to kill later.