Just a little potential gotcha...
I have also encountered this problem. The solution below works fine UNLESS the active control is a grid. If the active control is a grid then you have to actually find the active control INSIDE the grid (activecolumn) instead.
Otherwise the grid gets the focus in the example below but the Valid of the control that is being edited still never fires.
I have some code examples if you need further information.
Eric Shaneson
Cutting Edge Consulting
>Gilles,
>
>The reason you see the behavior you do is that a toolbar NEVER gets focus, so the textbox never loses focus. The controlsource is updated by the textbox after its valid fires, which occurs when it loses focus. Since in hasn't lost focus it hasn't updated its controlsource. The solution is to get VFP to make the textbox lose focus. You can do this by setting focus to the same textbox with code like this at the beginning of the toolbar button's code.
>
>
>IF TYPE("_screen.ActiveForm.ActiverControl.Name") = "C"
> IF PEMSTATUS(_screen.ActiveForm.ActiveControl, "Setfocus",5)
> _screen.ActiveForm.ActiveControl.SetFocus()
> ENDIF
>ENDIF
>* The rest of your button code here
>
Eric Shaneson
Cutting Edge Consulting