How to Keep Cursor in GET Object If Data Is InvalidLast reviewed: April 30, 1996Article ID: Q117591 |
The information in this article applies to:
SUMMARYThis article describes how to keep the cursor in a GET object if the data that was entered is invalid.
MORE INFORMATIONThe following code examples illustrate two ways of keeping the cursor in a GET object.
Example 1This example uses a GET field called m.pass and calls a UDF function named Testit() each time the cursor leaves the field. By default, the Testit() function will always return true (.T.), which updates the object with the current value. If invalid or incorrect data was entered in a field, you can return false (.F.), which keeps the original value unchanged in the GET field and displays an "Invalid Input" message.
*** Code begins here *** @ 5,0 GET m.pass DEFAULT ' ' VALID Testit() READ CYCLE FUNCTION testit IF m.pass = "Y" RETURN .T. ELSE RETURN .F. ENDIF *** Code ends here ***You can suppress the "Invalid input" message by returning a value of zero (0) instead of .F. For more information on using RETURN 0, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q90415 TITLE : Suppressing the "Invalid Input" Message in FoxPro Example 2The following code illustrates how you can force the cursor to remain in the same field object by setting the value of _CUROBJ (current object) to itself instead of using RETURN .F. in the called procedure.
*** Code begins here *** @ 5,0 GET m.anyx DEFAULT ' ' VALID Test2() @ 6,0 GET m.anyz DEFAULT ' ' READ CYCLE FUNCTION test2 WAIT WINDOW m.anyx TIMEOUT 5 _CUROBJ=_CUROBJ *** Code ends here *** |
Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |