Craig Bernston wrote:
>>Field data save problem in VFP 5.0
>>
>>I have a problem when moving off of a control in a form and clicking on
>>a save button on a tool bar. The data typed into the field does not get
>>saved unless I press Tab or Enter before clicking the tool bar. My
>>cursors are set to BufferModeOverride = 4. Anyone have them same
>>problem and correct it?
>
>In the LostFocus method of the textbox control, put the following:
>This.Value = This.Value
>
>It sounds crazy, but it works!
Michel Fournier wrote:
* Save the current buffer
* Call from Save() and AddNew()
* We need to make sure the hierarchy is not coming from a Valid() event
* because this will generate an error
* In Visual FoxPro 5, we are not allowed to call SetFocus() from a Valid() event
LOCAL lcProgram,lnCompteur
lcProgram=PROGRAM(1)
lnCompteur=2
DO WHILE LEN(lcProgram)>0
lcProgram=EVALUATE('PROGRAM('+ALLTRIM(STR(lnCompteur))+')')
lnCompteur=lnCompteur+1
IF UPPER(RIGHT(lcProgram,6))='.VALID'
RETURN
ENDIF
ENDDO
IF TYPE('_Screen.ActiveForm.ActiveControl')='O'
IF UPPER(_Screen.ActiveForm.ActiveControl.BaseClass)=='GRID'
* Test if this is an active grid column
IF _Screen.ActiveForm.ActiveControl.ActiveColumn0
IF UPPER(EVAL('_Screen.ActiveForm.ActiveControl.Columns(_Screen.ActiveForm.ActiveControl.ActiveColumn).'+;
TRIM(_Screen.ActiveForm.ActiveControl.Columns(_Screen.ActiveForm.ActiveControl.ActiveColumn).CurrentControl)+;
'.BaseClass'))='OPTIONGROUP'
_Screen.ActiveForm.ActiveControl.SetFocus()
ELSE
=EVAL('_Screen.ActiveForm.ActiveControl.Columns(_Screen.ActiveForm.ActiveControl.ActiveColumn).'+;
TRIM(_Screen.ActiveForm.ActiveControl.Columns(_Screen.ActiveForm.ActiveControl.ActiveColumn).CurrentControl)+;
'.SetFocus()')
ENDIF
ENDIF
ELSE
_Screen.ActiveForm.ActiveControl.SetFocus()
ENDIF
ENDIF
Actually it took both of you guys ideas to work. Either one by themself did not work. Here is what worked for me: I placed the following code in the click method of the Save button:
IF PEMSTATUS(_Screen.ActiveForm.ActiveControl, 'Value', 5)
_Screen.ActiveForm.ActiveControl.Value = _Screen.ActiveForm.ActiveControl.Value
ENDIF
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only