Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP doesn't allow calling of setfocus() from VALID event. 1

Status
Not open for further replies.

Russ1005

Programmer
Dec 13, 2004
96
US
In VFP 7, I have a program spec that says if the spinner control on the form doesn't contain valid data to reset the control's value to it's previous value and setfocus to the control. VFP does not allow you to call setfocus() from the VALID event. Any idea how I can set the focus?

Thanks.
 
You can test the validity of the value in the InteractiveChange event and set focus from there. -Jim
 
In addition to what Dave said, you can also return a numeric value from the valid. This is what I do to remind myself that the valid event can advance or move the focus backward based on the value returned.

Return (1) && Advance focus one control forward in the tab order

Return (0) && Do not allow this control to lose focus

Return (-1) && Move focus back one control in the tab order

...then there is the ability in VFP9 to return focus to a particular control which doesn't rely on the tab order at all...

Return (thisform.text1)

...note that this particular feature, while giving you lots of options and control (you can even set focus to a completely different form's objects) will fire the lostfocus event. What I mean is that if you specify the control for which the valid event is running...

Return(this)

...the lostfocus will fire. It doesn't fire when returning 0 or .F.



boyd.gif

SweetPotato Software Website
My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top