>Hi All,
>
>I'm been wrestling with a problem for a couple of days now.
>
>I have a combo that's sat on a form. My toolbar has a Save method and calls _screen.activeform.activecontrol.SetFocus() to ensure the combo's value gets updated properly before a save. Not elegant, I know<s>. Anyway, SetFocus calls various methods in turn (VFP's behaviour not mine) and the last piece of code to be executed before control is returned to the line after SetFocus is in the GotFocus of the combo's parent. If I allow this to execute I get a wierd "syntax error" message. This is odd as there's no more code to execute. I assume I've upset VFPs default behaviour but I can't see what I've done wrong to get round the problem.
>
>Any ideas?
>
>Regards
>
>Paul
Your technique of calling _screen.activeform.activecontrol.SetFocus() before saving is the generally accepted technique, so don't feel bad about it being "inelegant". As far as the problem you're having, I don't know why you would be getting this, but I can hazard a guess for a technique to fix it.
By calling the SetFocus(), you're causing the object to first loose focus, which fires the valid and lostfocus methods. Since that's what you're really after, you don't really need the code in the SetFocus to run at all. Try setting a form property called something like lSaving. In your Save method, set it to .T., then call _screen.activeform.activecontrol.SetFocus(), and then set it back to .F.
In the SetFocus of the object giving you the error, put:
If Thisform.lSaving
NODEFAULT
RETURN
Endif