Unbound Combo box: Selected text not showing

女生的网名这么多〃 提交于 2019-12-12 07:03:20

问题


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
  • 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
    

The combo box appears after selection

Combo box properties


回答1:


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


来源:https://stackoverflow.com/questions/37655385/unbound-combo-box-selected-text-not-showing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!