Hi Agnes.
Thanks. My field was not in a grid but I will keep this in mind.
>Hi Charles,
>the problem with KEYPRESS and fieldupdate is, that keypress runs in front of elements VALID(). But valid have to be run to update the value to the field.
>SETFOCUS() to the control itself runs VALID(). (just trace the events). The problem with the grid is, that _VFP.ActiveForm.ActiveControl points to the Grid not to the control in column. _VFP.ActiveForm (or APPLICATION.ActiveForm) may also point to somewhere else or to nowhere.
>
>To solve this:
>
>
>IF;
> TYPE('.ACTIVECONTROL')=T_Object;
> AND !ISNULL(.ACTIVECONTROL) THEN
> lvActive = .ACTIVECONTROL
> IF LOWER(lvActive.BASECLASS)='grid' THEN
> lcGrid = SYS(1272,lvActive)
> IF TYPE('THISFORMSET')='O'
> lcGrid = 'THISFORMSET'+SUBSTR(lcGrid,AT(".",lcGrid))
> ELSE
> lcGrid = 'THISFORM' +SUBSTR(lcGrid,AT(".",lcGrid))
> ENDIF
> lnColumn = lvActive.ACTIVECOLUMN
> lnColumn = IIF(EMPTY(lnColumn),1,lnColumn)
> IF !EMPTY(lvActive.COLUMNCOUNT) THEN
> lcControl = lvActive.COLUMNS(lnColumn).CURRENTCONTROL
>*Assuming column.name is allways COLUMNnn
> lvActive = EVALUATE(lcGrid+'.COLUMN'+ALLTRIM(STR(lnColumn,3,0))+'.'+lcControl)
> ENDIF
> ENDIF
>*comparsion of Objects introduced with VFP 6.0?
>*only if there is an ACTIVEFORM (VFP 7.0 dockable Windows causes errors)
> IF;
> TYPE(APPLICATION.ACTIVEFORM)='O';
> AND !ISNULL(APPLICATION.ACTIVEFORM);
> AND APPLICATION.ACTIVEFORM=THISFORM THEN
> lvActive.SETFOCUS()
> ENDIF
>ENDIF
>
>
>This fails with ActiveX objects like DateTimePicker.
>
>Agnes
>>I have a very basic form where the keypress event traps ctrl+up or down arrow to skip records. On this form are fields for editing data. When I type information in the field and do a ctrl+arrow without first exiting the field, the data is not written to the field. What is it I have to do in order to force the data to be written (a form.refresh does nothing)?
>>
>>Thanks in advance