Sub PurgeValidationRule(strForm As String, Optional strRuleText As String = "")
Dim boolRemoveAllValidation As Boolean
Dim c As Control
boolRemoveAllValidation = strRuleText = ""
DoCmd.OpenForm strForm, acDesign
For Each c In Forms(strForm)
If TypeOf c Is TextBox Or TypeOf c Is ComboBox Then
If boolRemoveAllValidation Then
c.ValidationText = ""
c.ValidationRule = ""
ElseIf c.ValidationRule = strRuleText Then
c.ValidationText = ""
c.ValidationRule = ""
End If
End If
Next c
DoCmd.Close acForm, strForm, acSaveYes
End Sub
|