Validate Field Value

The validation logic for a field in an editable control can be easily customized by specifying a formula for the “Validate When Saving record” event. For example, this formula checks whether the user has entered a ContactName:

= IF(CustomersRecordControl.ContactName.Text="" ,"Enter a value for Contact Name","")

Returning an empty string implies the input is valid and the record should be saved.

You can also perform multiple validations on the same field.  For example, this formula only allows passwords whose length is between 5 and 10.

= IF(LEN(UsersRecordControl.Password.Text) > 10 OR LEN(UsersRecordControl.Password.Text) < 5 , "Length of password should be between 5 and 10 characters", "")

Validation formulas may also contain functions. In the validation formula, database values can be used directly by using the column name.  For example, this validation formula requires a value to be present in the Zip Code field in the database for US addresses.

= IF(country=“USA” and ISBLANK(zipcode), “Zip Code must be provided for US addresses”, ““)

See Also

Common Formula Examples