Question : Loop through form controls and remove validation rule

I would like ot know if/how I can write a procedure to loop through all the valid controls in a form (textboxes and comboboxes to remove a bogus validation rule.  

Answer : Loop through form controls and remove validation rule

Oops. Wrong property. Try this...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
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
Random Solutions  
 
programming4us programming4us