Hugo,
Hard to say if it was really a bug or not. The idea of WriteBuffer is to make sure that the current data are always saved. So if you just typed something and then press x at the right corner or Exit button on the toolbar, it has to behave the same. In my case I partially saved it with alltrim and the x started to behave, but then Exit button still gave me the message.
So, based on the previous code I've taken from UT threads, I made the following code to be my current:
LOCAL loColumn, loActiveControl, loControl, llRetVal llRetVal = .T. IF TYPE('Thisform.ActiveControl.Name' ) = 'C' loActiveControl = THISFORM.ACTIVECONTROL IF UPPER(m.loActiveControl.BASECLASS ) # 'GRID' *** If there is code in the valid method of the active control *** And the entry is invalid, the error message will display *** But the rest of the code code will continue to run and save *** the bad data anyway. So we cannot just issue a SetFocus() IF PEMSTATUS(m.loActiveControl, 'value', 5) IF NOT EMPTY( loActiveControl.VALID() ) *** We still have to cause the Valid to fire to update the data *** from what is in the buffer because the previous line *** does not cause the Valid to fire, it merely runs any code *** in that method llRetVal = .T. ELSE llRetVal = .F. ENDIF IF NOT EMPTY(m.loActiveControl.ControlSource) ; AND EVALUATE(m.loActiveControl.ControlSource) <> m.loActiveControl.value loActiveControl.value = m.loActiveControl.value endif loActiveControl.SETFOCUS() endif ELSE FOR EACH loColumn IN loActiveControl.COLUMNS IF loActiveControl.ACTIVECOLUMN = loColumn.COLUMNORDER loControl = EVALUATE( 'loColumn.'+ loColumn.CURRENTCONTROL ) IF NOT EMPTY( loControl.VALID() ) loControl.SETFOCUS() llRetVal = .T. ELSE llRetVal = .F. ENDIF EXIT ENDIF ENDFOR ENDIF ENDIF RETURN llRetVal