3

I have the validation rules set in the design table and I want to test it before I save the changes done in the recordset.

Thor My
  • 269
  • 2
  • 8
  • 23

1 Answers1

-1

Use a form to enter the data.

Then use the same validation rules in the BeforeInsert and BeforeUpdate events of the form.

Gustav
  • 53,498
  • 7
  • 29
  • 55
  • 1
    yes but, how to test the validation rules programmatically? eg: if ( TestValidationRule(control.Value, recordset.ValidationRule) ) then recordset.Update notice that I refer to the recordset's validation rule, not the control's one. – Thor My Apr 29 '15 at 20:14
  • You can in the control properties replicate the validation rule for the field ans also specify a message. However, it far more flexible to use the BeforeUpdate and/or BeforeInsert events. Set Cancel = True in case of a validation error. – Gustav Apr 30 '15 at 06:08
  • 1
    hi Gustav. thanks for you assistance. I got it without replicating the validation rule. I'm still working on the code so I didn't post it here yet. I access the table's field validation rule via recordset properties and test it programmatically. if the test returns true, I save the changes done in the recordset (recordset.Update). if it returns false, I run a message box showing the validation text also got thru the recordset (recordset.Fields(control.RecordSource).ValidationText). it is working fine for me. – Thor My Apr 30 '15 at 11:21