【发布时间】:2021-12-13 08:11:24
【问题描述】:
我有一个多列组合框,现在尝试搜索代码,但无济于事。
这是我的组合框的样子:
emp_id emp_name
--------- ---------------
<blank> - Select -
1 James Bond
2 Jason Statham
3 Sylvester S.
4 Chuck Norris
其中columnwidths = "0,100" and and columnheads = False,所以它只会显示emp_name
我想要做的是,以编程方式选择并显示基于变量的组合框中的项目
到目前为止,与我想要实现的最接近的逻辑是:
empSysID = 3 '~This is Sylvester S.
With .ComboBoxEmployee
For i = 0 To .ListCount - 1
If .Column(0, i) = empSysID Then
.Value = .List(i) '~Trying to select and display 'Sylvester S.' in combobox
Exit For
End If
Next i
End With
但我收到运行时错误“380”:无法设置值属性。无效的属性值。
提前谢谢你!
【问题讨论】:
-
.ListIndex = i?