Share via


CDaoTableDef::SetValidationRule

Call this member function to set a validation rule for a tabledef.

void SetValidationRule( 
   LPCTSTR lpszValidationRule  
);

Parameters

  • lpszValidationRule
    A pointer to a string expression that validates an operation.

Remarks

Validation rules are used in connection with update operations. If a tabledef contains a validation rule, updates to that tabledef must match predetermined criteria before the data is changed. If the change does not match the criteria, an exception containing the text of GetValidationText is displayed.

Validation is supported only for databases that use the Microsoft Jet database engine. The expression cannot refer to user-defined functions, domain aggregate functions, SQL aggregate functions, or queries. A validation rule for a CDaoTableDef object can refer to multiple fields in that object.

For example, for fields named hire_date and termination_date, a validation rule might be:

myTableDef.SetValidationRule(_T("termination_date > hire_date"));

For related information, see the topic "ValidationRule Property" in DAO Help.

Requirements

Header: afxdao.h

See Also

Reference

CDaoTableDef Class

Hierarchy Chart

CDaoTableDef::GetValidationText

CDaoTableDef::SetValidationText

CDaoTableDef::GetValidationRule

Other Resources

CDaoTableDef Members