Hi John,
I note with interest the reply from Jeff Pace. I'll be looking into that for sure.
I use the setfocus() approach as originally put forward by Jim Booth in '97 ( see what good documentation does :-), however his approach failed on grids (at least it did in VFP3) where i used the following mod. I think this problem partially convinced Jim never to use grids for editing. But we had great success once this code was in place.
IF TYPE("thisform.ActiveControl.Name") = "C"
LOCAL oC, oAC
oAC= thisform.ActiveControl
IF oAC.Baseclass = "Grid"
LOCAL nColumn, cControl
nColumn= oAC.ActiveColumn
IF BETWEEN(m.nColumn, 1, oAC.ColumnCount)
oC= EVALUATE("oAC.Columns(nColumn)." + oAC.Columns(m.nColumn).CurrentControl)
oC.SetFocus()
ENDIF
ELSE
oAC.SetFocus()
ENDIF
ENDIF
You see the currentcontrol of the grid needs to get the set focus not the activecontrol of the form. I suspect the same logic might apply to Jeff's approach.
>Hi all ---
>
>Many of y'all know this one but many more might not. I had forgotten it and it bit me in the butt with a client:
>
>When calling a Save routine from a Toolbar button or Menu option, the changed data in the current control may not be saved. Why? Because the Control never really loses focus and, therefore, the underlying ControlSource is not updated with the new Value.
>
>The trick is to force a LostFocus. A good way to do that is to SetFocus() to an OK button or other non-databound control in the same Form.