Code Validation

If you select the Code field validation type, the Integrity dialog looks like this:

An editable window appears on the Integrity page with an “LPARAMETERS” line entered. Leave the LPARAMETERS line as is and add your code after it.

The code you enter is stored in memo fields in the Field Data table, SDATADDF.DBF. The code is executed using the EXECSCRIPT() function.

When you choose Code validation for a field, you write Visual FoxPro code to validate the field. At the time your code is run:

·       Field Value: The memory variable stValue contains the field value to validate.

·       Return Property: Your code must set the data handler object’s stoCallingObject.FieldValidationReturnValue property to false (.F. or 0) if the field fails validation. (The object reference of the data handler object is stored in “stoCallingObject”.)

·       Error Message: Your code can return the error message to display if the field fails validation by assigning the message as a character string to the data handler object’s stoCallingObject.cFieldValidationReturnMessage property.

Use Code validation if the validation rules you need to apply to a field are too complex for one of the standard VPME validation types.

Ø To create Code validation for a field

1.   Select Code validation on the Type combo box. VPME transforms the Integrity page for Code validation.

2.   Enter your code in the window on the Integrity dialog.

Tip – Writing Code: To learn much more about how to create Code validation code, read Field-Level Data-Driven Developer Code. That section contains coding tips and explains how to use the parameters passed to your code.

3.   After entering your code, click the Options combo box to turn on validation for the field. Choose the validation option that you want.

4.   If you want to allow users to override an entry that fails validation, check the Override check box.

5.   Click the Level combo box to select when field validation should be run.

6.   When you leave the Integrity page for the field, VPM Enterprise will save your changes.

More:

Not Empty/Null Validation