>>In following code I need to guarantee the focus goes to the first readable control. I don't know the Tabindex of the first control because depends of the form, and this code is inside class and not always the first control is readable or has the property tabindex.
>>
>>In my case (after instantiate the form class)
>>the first control is a textbox readonly=.f., tabindex=1,
>>the second control is a textbox readonly= .t., tabindex=2,
>>the third control is a combobox readonly=.t., tabindex=3
>
>
>>
>>FOR EACH oCont IN Thisform.Controls
>> IF oCont.Baseclass = 'Pageframe'
>> FOR EACH Ctrl IN oCont.Page1.Controls
>> IF PEMSTATUS(Ctrl,'TabIndex',5) = .T. AND ;
>> PEMSTATUS(Ctrl,'Readonly',5) = .T. AND ;
>> Ctrl.Readonly = .F.
>> Ctrl.SetFocus()
>> EXIT
>> ENDIF
>> ENDFOR
>> EXIT
>> ENDIF
>>ENDFOR
>>
>
>>What is happening is that instead the focus goes to the second control (tabindex=2) is going to third (tabindex=3). What is wrong?
>
>
>There is no guarantee that the contols are in tab order. If you keep a variable that holds the smallest tab order and don't accept any tab orders with a number greater than that one, that should work.
By the way in this scenario you have to loop through all the controls.
>
>Dan