How to clear all control’s values in a form
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 'Controls - How to clear all control's values in a form ' Clear All Form Controls (using type of control) On Error Resume Next 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) On Error Resume Next 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 |
Related posts:
- How to Clear all TextBoxes in a Form
- How to Clear all TextBoxes on the form
- How to clear the text in active control if the active form name is “frmCustomer”
- How to make a preferences Form
- How to clear the contents of all the items in an array of TextBox controls
- How to load the values of a recordset in a combo box
- How to select all text with Ctrl+A in all TextBoxes in a form
- How to count the number of textboxes in a form
- How to Enable/Disable all Controls in a frame
- How to reposition and resize all the controls on a form whenever the form is resized.