Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling SetFocus from within a Valid
Message
From
27/03/1998 15:06:52
 
 
To
27/03/1998 14:57:10
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00087717
Message ID:
00087793
Views:
34
>>>>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
>Bob,
>I prefer lostfocus too but didn't throw away valid completely yet. TAB approach should be tried I think (didn't try so assume) it wouldn't fire the other control's valid but give a chance to complete current and also reevaluate any necessary "when" (maybe would problem) and then sitting on an available control. I'm not sure but this approach were somewhat mentioned in "dosave" method article by Jim Booth (I should read it again carefully).
>Now that nodefault. If you're going to "validate" via lostfocus then you wouldn't want a control *lose focus* w/o valid data. Setting focus to self in lostfocus is only possible by having a nodefault in lostfocus (otherwise lostfocus default would cause a *lose focus* - keep away from me).
>Cetin

Worth checking. I'll play with the TAB approach on the weekend
Bob
Previous
Reply
Map
View

Click here to load this message in the networking platform