Hi everyone,
I have a userform with many comboboxes and textboxes and I am using the following code to empty those controls:
Private Sub CommandButton2_Click()
Beep
If MsgBox("Are you sure you want to clear all form fields?", vbQuestion + vbYesNo, "Confirmation") = vbYes Then
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
TextBox11 = ""
TextBox12 = ""
ComboBox1 = ""
ComboBox2 = ""
ComboBox3 = ""
ComboBox4 = ""
ComboBox5 = ""
ComboBox6 = ""
End If
TextBox2.SetFocus
End Sub
Is there another way to clear contents of all comboboxes and textboxes instead of that one in order not edit the code in case of adding new controls.
Thanks,
Bookmarks