Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VALID=.F. except when you press CANCEL?
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00176248
Message ID:
00176401
Views:
23
>In many situations, I'll want a user to stay in the current field until they enter a valid value - OR - until they press the CANCEL button! I know that I can keep them in the field by returning .F. in the VALID method, but how can I account for that CANCEL button?
>
>TIA

You can thank Doug Hennig for this code

* If the Valid method is fired because the user clicked on a button with the
* Cancel property set to .T. or if the button has an lCancel property (which
* is part of the C40CommandButton base class) and it's .T., don't bother doing
* the rest of the validation.

local oObject
oObject = sys(1270)
if lastkey() = 27 or (type('oObject') = 'O' and ;
type('oObject.lCancel') = 'L' and oObject.lCancel)
return .T.
endif lastkey() = 27 ...

* Do the custom validation (this allows the developer to put custom validation
* code into the Validation method rather than having to use code like the
* following in the Valid method:
*
* dodefault()
* custom code here
* nodefault

return This.Validation()


This will allow the user to have bad data in a field and press the cancel button to get out of the field and cancel the operation. Hope this helps
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Reply
Map
View

Click here to load this message in the networking platform