0

Hi all,

I want to clear all items of comboboxes in my form
I can clear all textboxes using looping and check if control is textbox then clear textbox. But when i implement it to combobox it just clear the combobox text not all of items on combobox.

Private Sub ClearCombo_Click()
Dim Temp As Control
For Each Temp In Me.Controls
    If TypeOf Temp Is ComboBox Then
        Temp.Text = ""
    End If
Next
End Sub

Please help me.

Thank you in advanced.

2
Contributors
2
Replies
6
Views
5 Years
Discussion Span
Last Post by Sturdy
1

Try this :

Private Sub ClearCombo(ByVal MyCombo As ComboBox)
    MyCombo.Clear
End Sub

Private Sub ClearCombo_Click()
Dim Temp As Control
For Each Temp In Me.Controls
    If TypeOf Temp Is ComboBox Then
        Temp.Text = ""
        ClearCombo Temp
    End If
Next
End Sub
Votes + Comments
Solved
0

Thank you for quick reply sir.
That code working very nice.
Thanks again.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.