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.

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
commented: Solved +1

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.