JavaScript Editor js editor     Web development 



Main Page

You can create local versions of field and record validation rules for views. Creating local validation rules provide the following benefits:

However, Visual FoxPro does not compare the validation rules that you create locally with the validation rules in the remote data source. Therefore, you must create rules that are appropriate and compliant with the remote data source. If remote data source rules change, the local validation rules must match.

For more information, see Working with Validation Rules.

To create a field or record validation rule for views

  1. Open the view in the View Designer, and click the Fields tab.

  2. In the Selected Fields list, click a field, and click Properties.

  3. In the Rule box from the Field validation area, type the validation expression you want. To build an expression, click the ellipsis (...) button.

  4. To display a custom error message, in the Message box, type the custom error message or expression you want to display for invalid values. To build an expression, click the ellipsis (...) button.

    Note:
    Make sure to enclose message text in quotation marks ("").

To create a field or record validation rule for views programmatically

  • Use the DBSETPROP(В ) function to set the RuleExpression and RuleText field or record properties for views.

For more information, see DBSETPROP( ) Function.

For example, the following code creates a field-level rule on orditems_view that prevents entering a quantity of less than 1:

В Copy Code
OPEN DATABASE testdata
USE VIEW orditems_view
DBSETPROP('Orditems_view.quantity','Field', ;
         'RuleExpression', 'quantity >= 1')
DBSETPROP('Orditems_view.quantity','Field', ;
         'RuleText', ;
'"Quantities must be greater than or equal to 1"')

See Also



JavaScript Editor js editor     Web development 

©

©©