>>>I did force a SetFocus() on one of my control whenever I call the Refresh() method. This solves the problem.
>>>
>>>I was wondering, instead of adding a control, is there a way to detect the control #1 in the tab sequence so we can focus on that?
>>
>>You could loop through the Controls() collection looking for the first visible control that has a SetFocus method that is not a grid, but I think that would be a PITA.
>
>The advantages of it is that we will set the focus to the first control of the form, the focus will be on a visible one so we will see and we won't have to handle an extra control to handle that workaround.
I have only tested this code for the conditions in it. There may be other factors that prevent a control from receiving focus, like visible property.
local loMinControl
loMinControl = .null.
for each loControl in ThisForm.Controls
if isnull(loMinControl)
if upper(loControl.BaseClass) <> "GRID" and pemstatus(loControl, 'SetFocus', 5) and loControl.Enabled
loMinControl = loControl
endif
loop
endif
if upper(loControl.BaseClass) <> "GRID" and pemstatus(loControl, 'SetFocus', 5) and loControl.Enabled
if loControl.TabIndex < loMinControl.TabIndex
loMinControl = loControl
endif
endif
endfor
if not isnull(loMinControl)
loMinControl.SetFocus()
endif
Mark McCasland
Midlothian, TX USA