Microsoft KB Archive/161864

= PRB: Return 0 in TextBox Valid Allows Switching Active Form =

Article ID: 161864

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q161864



SYMPTOMS
The Help for Visual FoxPro states the following about the Valid event of a control:

If 0 is returned, the control does not lose focus.

This is true if you try to move between controls on a single form. But if a control returns 0 in the Valid event, you will be able to move the focus to a different form.



RESOLUTION
To prevent the control from losing focus, you should return .F. (False) from the Valid event of the control: RETURN .F. To disable the "Invalid Input" message that a False (.F.) return value causes, issue the following command: SET NOTIFY OFF This should be done at the start of an application or in the Init event of a form.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a form called AAA. Add two text boxes to the form.  In the Valid of Text1 add the following code: IF EMPTY(This.Value) RETURN 0 ENDIF  Save the form. Create a form called BBB, and add a text box control to it. Save and run form BBB.</li> Run form AAA.</li> Try to Tab from the first text box to the second text box on form AAA. Then click on form BBB.

You will not be able to move from Text1 to Text2 on form AAA as long as Text1 is empty. But you will be able to click on form BBB and make it the active form.</li></ol>

Keywords: kbbug KB161864

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.