Microsoft
Software
Hardware
Network
Question : How do I access another column of data in a ComboBox?
Merry Christmas, experts. I hope someone is out there.
Here's my situation:
I have a Codes table with two fields, "Code" and "Description". I have successfully added the codes to the ComboBox, cboDocType, and want to access the "Description" column when the user selects a code in the combobox. The "Description" needs to go into a label control, "labCode", so that the user will know that they selected the correct code. What code do I need to accomplish this? Here's my code so far:
Dim dsCodes As New DataSet
Dim codesAdapter As New SqlDataAdapter("SELECT * FROM Codes ORDER BY Code", myConnection)
codesAdapter.Fill(dsCodes,
"Codes")
cboDocType.DataSource = dsCodes.Tables("Codes")
cboDocType.DisplayMember = "Code"
cboDocType.ValueMember = "Code"
labCode.Text = "I want to display the Codes.Description here."
Thank you.
Answer : How do I access another column of data in a ComboBox?
How about changing
cboDocType.DisplayMember = "Code"
cboDocType.ValueMember = "Code"
to
cboDocType.DisplayMember = "Code"
cboDocType.ValueMember = "Description"
Then in the SelectedIndexChanged event
labCode.Text = cbDocType.SelectedValue
Random Solutions
How do I parameterise a Union query so that a prompt it not issued each time it runs...
Excel Exception from HRESULT Error
How to create a "Link Label"?
SQL Query - Syntax ( SQL 2005 / 2008 )
Get ListViewItem Checked state by Index in VB .NET
Conditional Concatenation in a Query
First NSLookup always times out
How will adding a VBA reference to ADO 2.8 affect my database?
How to create a list of sub folders?
Access qurery not showing the right data with linked SQL 2005 tables