Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you prevent Bypass of Field validation
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00190601
Message ID:
00190988
Views:
17
>>Dan ---
>>
>>Move your validation rules into a separate business object (just a Custom object with custom properties, nothing fancy). Call the appropriate method on Valid *and*, as Ed suggests, in your Save code. Make sure that you use a SetFocus to move the cursor back to the offending control also for consistency.
>>
>>
>
>I like this idea.
>
>Should I have a business object for each control? Maybe have a flag, used when the form is originally instantiated, that determines if a business object should be created for each control? How will this affect the performance of the app?

It will not hurt the app performance more than if you add an extra label control to your form.
Actually it does not matter much where your validation rules will be located, in the object or in the custom form methods. It is just a question of design. Anyway, you have to use the LostFocus() method instead of Valid() to call the other validation methods. VFP will still complain that it "Cannot call SetFocus from within a When, Valid, RangeHigh or RangeLow event" when you will try to SetFocus() in your extra validation method.

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Reply
Map
View

Click here to load this message in the networking platform