Clearing All Form Controls:   Return to List

' Clear All Form Controls (using TypeOf)
Dim ctl As Object
For Each ctl In Me.Controls
    If TypeOf Ctl Is CheckBox Then
        ctl.Value = False
    ElseIf TypeOf Ctl Is TextBox Then
        ctl.Text = ""
    ElseIf TypeOf Ctl Is Combobox Then
        ctl.Text = ""
        ctl.Clear
    End If
Next

' Clear All Form Controls (using name)
Dim ctl As Object
For Each ctl In Me.Controls
    If Left(ctl.Name, 3) = "chk" Then
        ctl.Value = False
    ElseIf Left(ctl.Name, 3) = "txt" Then
        ctl.Text = ""
    ElseIf Left(ctl.Name, 3) = "cbo" Then
        ctl.Text = ""
        ctl.Clear
    End If
Next



Note to Webmaster