Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Required Fields?
Message
From
16/01/1997 10:57:58
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00017517
Message ID:
00017526
Views:
56
>I was surprised as I was working on a project the other day. I had a field that is required under certain conditions. To take care of this I placed a bit of code in the Valid method of the combobox that is bound to this field and didn't give it a second thought. As I was testing my changes, however, I was surprised to find that the valid method was not being fired unless the user changes the value of the combobox. I was under the impression that the Valid method always fires right before a control looses focus. Well, apparently not. At least not for comboboxes.
> Being the clever programmer I am, I figured I would call the valid method from the lostfocus to ensure it was being fired, but even though the valid method returned .F. as it was supposed to, the control still lost focus.
> By this time I was becoming annoyed and feeling like I was trying to jump through hoops just to do something that most any programmer would need at one time or another--validate the value of a field once it has lost focus.
> I'm wondering why controls don't have a "required" property that, if set, won't let them loose focus unless a value is entered. But, I digress. What do other people use to ensure a control is not left blank once it has focus?
>
>
>Michael G. Emmons

My general approach is not to use individual Valid events. Instead of this I put data saving code under 'Save' button and Enable/Disable this button depending on data-entry conditions, i.e. I fire custom Thisform.EnableSave method from any place (mostly Programmatic/InteractiveChange Events) where some required control may change value. Surely this approach presumes thet I don't use ControlSources for textboxes.
Edward Pikman
Independent Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform