How do you set a combo box to populate with two column fields? Having one field hidden as a datafield and the other fields as an display field for user to choose which information they want. Are is there another way to do it?
I was hoping Visual Basic combo box would be similar to Access. After two days of researching about it and testing it, I have no luck with it. I need y'all help, please. My mind will go insane if I don't figure out how it works...
you have not said any thing about the error messages. Just tell me the error messages u are getting or the type of problem you are facing. The aboe code works only with normal combo box. For data combo you have to use it in a different way. You have to put an adodc control on the form. The code is give below
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.ConnectionString = m_cnnGlobal.ConnectionString ' my connection str
.RecordSource = "Select EmpID,EmpName from Employees"
Set .DataSource = Adodc1
Set .RowSource = Adodc1
.BoundColumn = "EmpID"
.ListField = "EmpName"
here EMPID is hidden and EmpName is visible.
You can add more columns to the select statement and get the values by filtering the adodc
on clickevent of the datacombo
varEmpID = Val(Trim$(cmbdatacombo.BoundText))
with the above variable just filter the adodc and get the values for other columns too.
Hope that this helps you.
If you face any other problem pl write the problem with the error message
after putting Mr.. sudheesh_k_s code in form everything worked until I make probe exe file and then after passing to another control on form, item in DataCombo always return to first record in table from which it was populated!! Please check!
Can you paste the code written on the click event of the combo and if you have written code for any other event of the combo please put them too. And also please let me know the other controls on which the focus goes after exiting the combo