我在表单上有大约8个组合框。当用户单击“重置”按钮时,我希望所有组合框在组合框中显示第一个项目数据。下面的代码返回null并且不起作用:
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
答案 0 :(得分:2)
如果您正在使用MS Access,则需要执行以下操作:
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
假设您要将所有组合框设置回空值。
答案 1 :(得分:0)
试试这个:
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
答案 2 :(得分:0)
像Me.Combo1.SelectedIndex = 0
...一般