>>>In the Keypress event of my form, I allow the user to press F3 to open a new additional (different) form.
>>>
>>>If the user presses F3 when the focus is on a textbox that has code in it’s valid event (even if the code is just a WAIT WINDOW), and if the form that is called calls the SetFocus() method of one of it’s controls (very common in the init’s of most of my forms) then I get the error message:
>>>
>>>"Cannot call SetFocus from within a When, Valid, RangeHigh, or RangeLow Event."
>>>
>>>I could solve my problem by getting rid of either my Valid or my SetFocus, but because I want them both, I’m looking for a different approach.
>>Kill the valid method by moving it to lostfocus.
>>
>>*Lostfocus
>>if !thisvaliddata
>> nodefault
>> this.setfocus
>>endif
>>
>>Or better, first move to another control (ie: keyboard "{TAB}") thus valid does its job.
>>Cetin
>
>The keyboard "{TAB}" solution won't work for me because I'm looking for a general solution and I don't know if the next control in the tab order has code in it's Valid or not.
>
>I much prefer the LostFocus approach. The approach here would be to abandon ALL use of the Valid method and use LostFocus instead EXCLUSIVLY. I remember this approach being suggested before on the thread, but at that time the reason was kind of vague to me and seemed to centre on Valid being an old style approach and LostFocus being newer. In any case, now I have a reason to change.
>
>Thanks for your input Cetin. By the way, how necessary is that nodefault in your example. I can't quite see where it would help me.
>
>Bob
NODEFAULT prevents hidden VFP base code from firing providing way for SetFocus(), else focus will go to the next control by tab sequence.
Edward Pikman
Independent Consultant