Reputation: 2471
I have about 8 combo-boxes on a form. When a user clicks the button "reset" I would like all the combo boxes to display the first itemdata in the combo box. The code below returns null and doesn't work:
Private Sub Command1_Click()
Me.Combo1.ItemData (1)
Me.Combo2.ItemData (1)
Me.Combo3.ItemData (1)
Me.Combo4.ItemData (1)
Me.Combo5.ItemData (1)
Me.Combo6.ItemData (1)
Me.Combo7.ItemData (1)
Me.Combo8.ItemData (1)
End Sub
Upvotes: 1
Views: 2335
Reputation: 1647
If it's MS Access your working with, you'll need to do something like this:
Private Sub Command1_Click()
Me.Combo1.Value = Nothing
Me.Combo2.Value = Nothing
Me.Combo3.Value = Nothing
Me.Combo4.Value = Nothing
Me.Combo5.Value = Nothing
Me.Combo6.Value = Nothing
Me.Combo7.Value = Nothing
Me.Combo8.Value = Nothing
End Sub
Assuming you want to set all the ComboBoxes back to a blank value.
Upvotes: 2
Reputation: 66727
Try this:
Private Sub Command1_Click()
Me.Combo1.SelectedIndex = 0
Me.Combo2.SelectedIndex = 0
Me.Combo3.SelectedIndex = 0
Me.Combo4.SelectedIndex = 0
Me.Combo5.SelectedIndex = 0
Me.Combo6.SelectedIndex = 0
Me.Combo7.SelectedIndex = 0
Me.Combo8.SelectedIndex = 0
End Sub
Upvotes: 0