Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving changes from a textbox without exiting
Message
 
To
24/01/2001 12:26:51
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00467981
Message ID:
00468006
Views:
21
You can call it in your Save method
llError = !thisform.WriteBuffer()
Just before you actually save.
In your case as the first line of your save buttons click event
PS. This is a custom method of my base form class.
But you can alos write this in a procedure.
If you call it from a toolbar or something outside of the form, first check that there is really a form active. If so, then you can give the object reference to that form to the function. Of course you need to replace thisform with the object reference name.
Some code
if TYPE("_screen.activeform") == "O" and UPPER(_screen.activeform.BaseClass) = "FORM"
   lError = WriteBuffer(_screen.activeform)
   ... code for saving
endif

Function WriteBuffer
LParameter toForm
LOCAL llRetval
llRetVal = .T.

*-- Code to save field value to buffer when
*-- clicking on toolbar without leaving the field
*-- Don't do this for a grid since a grid may change
*-- work areas unexpectedly
IF TYPE("toForm.ActiveControl") == "O" AND ;
    UPPER(toForm.ActiveControl.BaseClass) <> "GRID"
  IF TYPE("toForm.ActiveControl.ControlSource") <> "U" AND ;
      !EMPTY(toForm.ActiveControl.ControlSource)
    IF EVAL(toForm.ActiveControl.ControlSource) <> toForm.ActiveControl.Value
      REPLACE (toForm.ActiveControl.ControlSource) WITH toForm.ActiveControl.Value
      *-- We rely on the fact that we revert the field's value
      *-- in the error event method for the form. 
      llRetVal = (EVAL(toForm.ActiveControl.ControlSource) = toForm.ActiveControl.Value)
    ENDIF
  ENDIF
ENDIF

RETURN llRetVal


>Ko,
>
>Thanx... But, where would I put this code?
>
>Mike
>>>I have a form with a toolbar. On the toolbar I have a save button. Normally a user will add or edit the data on the form and click save on the toolbar, and everything works...
>>>
>>>However, I have on particular user that wants to change the data in one textbox, and then click save. This does not work, the user needs to change the data and then hit TAB or ENTER then click save.
>>>
>>>Putting the SAVE button on the form allows this behavior, but I want to keep the SAVE button on the toolbar...
>>>
>>>Is there a way to get this to work with the SAVE button on the toolbar?
>>>
>>>Thanx,
>>>
>>>Mike
>>

>>I have a writebuffer method for that:
>>
LOCAL llRetval
>>llRetVal = .T.
>>
>>*-- Code to save field value to buffer when
>>*-- clicking on toolbar without leaving the field
>>*-- Don't do this for a grid since a grid may change
>>*-- work areas unexpectedly
>>IF TYPE("thisform.ActiveControl") == "O" AND ;
>>    UPPER(thisform.ActiveControl.BaseClass) <> "GRID"
>>  IF TYPE("thisform.ActiveControl.ControlSource") <> "U" AND ;
>>      !EMPTY(thisform.ActiveControl.ControlSource)
>>    IF EVAL(thisform.ActiveControl.ControlSource) <> thisform.ActiveControl.Value
>>      REPLACE (thisform.ActiveControl.ControlSource) WITH thisform.ActiveControl.Value
>>      *-- We rely on the fact that we revert the field's value
>>      *-- in the error event method for the form.
>>      llRetVal = (EVAL(thisform.ActiveControl.ControlSource) = thisform.ActiveControl.Value)
>>    ENDIF
>>  ENDIF
>>ENDIF
>>
>>RETURN llRetVal
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform