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.
            Asked
            
        
        
            Active
            
        
            Viewed 933 times
        
    3
            
            
        - 
                    are you using access forms to enter the data? how is the data entered? – Vincent De Smet Apr 29 '15 at 07:33
 - 
                    yes, I'm using Access form. the data is entered via bound form. the validation rules are saved in the form's source table, not in the form's controls. – Thor My Apr 29 '15 at 20:13
 
1 Answers
-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
 
- 
                    1yes 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
 - 
                    1hi 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