>I've read a couple of articles this week about saving data regarding if the activecontrol's value gets saved after a menu hit or toolbar hit where the activecontrol doesnt lose focus so valid doesnt fire and if any buffers are dirty. One of the articles, A Classy way to Save Changes is by Jim Booth and the other is Outfoxed by Charlie Schreiner. Has there been any more current articles published concerning these things?
John,
This is a very simple issue. VFP controls update their controlsource during the processing of the Valid event. The Valid event of a contrl fires when teh control tries to lose focus. Toolbars and menus NEVER get focus. Accessing a toolbar or menu does not force the curretn control to lose focus, thus its Valid does not fire, thus it does not update its controlsource. There's not a lot more to say about it.
The solution is to insure that any toolbar or menu action that is going to address the buffered data forces the current control to fire its Valid before processing the data. This can be accomplished by simply having the current control set focus to itself. The only gotcha is that it is possible for a fomr to have no activecontrol or to have an active control that does not have a SetFocus method. So the code needs to be wrapped to insure no errors. Ultimately something like this will work;
IF TYPE("_SCREEN.ActiveForm.ActiveControl.Name") = "C" AND ;
PEMSTATUS("_SCREEN.ActiveForm.ActiveControl","SetFocus",5)
_screen.ActiveForm.ActiveControl.setfocus()
ENDIF