You can work around this limitation, in VFP 9 at least, by RETURNing to the 
control/object that you want to set focus to like so:

<some code that doesn't pass your validation test but you want to let the user 
go somewhere else>
RETURN thisform.myControlToSetfocusTo

This is documented in the VFP 9 help

"In Visual FoxPro 9.0, the SetFocus method is not supported in the When Event, 
Valid Event, RangeHigh Event and RangeLow Event events. However, you can 
include a RETURN Command with an object name (RETURN <ObjectName>) in these 
events to set the focus to another control. If a RETURN command with an object 
name is included, the focus is set to the control specified with <ObjectName>."

--
rk


-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Gene 
Wirchenko
Sent: Thursday, April 25, 2013 1:25 PM
To: [email protected]
Subject: RE: Review of My Application

<snip>
There is another factor.  If one has certain events on the execution stack, one 
can not use SetFocus.  That will throw an error
2012 ("Cannot call SetFocus from within a When, Valid, RangeHigh or RangeLow 
event.")
<snip>


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/DF1EEF11E586A64FB54A97F22A8BD0442190E5159F@ACKBWDDQH1.artfact.local
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to