未绑定的组合框:未显示所选文本 [英] Unbound Combo box: Selected text not showing
问题描述
我有一个未绑定的组合框,该框在表单加载时填充.我想要的是当用户选择组合框文本时,我应该能够访问其值.在这种情况下,选定的项目文本在选定时会消失,但是我可以访问其值.下面是组合框设置.我应该怎么做才能使组合框显示选定的文本,同时我应该能够访问选定的值?
I have a unbound combo box which I am populating on form load. What I want is when user selects the combo box text, I should be able to access its value. In this case, selected item text disappears when selected but I can access its value. Below are the combo box setting. What should I do to make combo box show the selected text and at the same time I should be able to access the selected value?
ID Process
1 a
2 b
3 c
- 列数-2
- 列宽-0,1"
-
行源类型-表/查询
- Column Count - 2
- Column Widths - 0",1"
Row Source Type - Table/Query
Private Sub Form_Load() Dim strSQL As String strSQL = "Select ID as F1 , process_name as F2 from tblProcess" Set objRecordset = New ADODB.Recordset objRecordset.Open strSQL, objConnection, adOpenKeyset, adLockOptimistic If Not (objRecordset.EOF And objRecordset.BOF) Then Set Me.cmbProcess.Recordset = objRecordset End If objRecordset.Close Set objRecordset = Nothing End Sub
选择后出现组合框
组合框属性
推荐答案
如果跳过整个objRecordset代码块,而是只在定义strSQL之后插入该行,它是否可以正常工作:
Does it work properly if you skip the whole objRecordset block of code and instead just insert the line after strSQL is defined:
Me.cmbProcess.RecordSource = strSQL
这篇关于未绑定的组合框:未显示所选文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!