Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Doing a lookup from a combobox

Status
Not open for further replies.

sk8er1

Programmer
Jan 2, 2005
229
US
I have a table with 28,000 names. I have loaded a combobox via a datareader. I would like to be able to do a lookup by navigating the the name in the combobox, then click on it and display the record -- I have done this in Access.
 
Populate a DataTable and bind the combo box and other controls such as textboxes, etc to the columns in the DataTable.
 
OK I populated the dataset with a fill command...and I bound the combobox to the datasource.....

But how do I "move the cursor to the appropriate record" and then do I have to load those values to the text boxes....
 
Does anyone have a sample on how to get a loaded combobox to move to the appropriate record when you click on one of the choices....like the Access combobox.

In my access apps, I have a lookup (combobox loaded with customer names) you simply click on the name, and that record loads...I want to do the same thing in VB.NET
 
I am doing this in an application I am converting from Access to VB.Net.

I have a dataset that contains the location names and unique record key that I want to use in my combo box (key is optional but speeds up reading). The second dataset has the data I want displayed on the form and the select query has 1 parameter (the record key).

The combo box is populated from dataset1 where the datasource is ds1 and the displaymember is Location. The valuemember is the unique key tied to the location.

On the cboField_selectedvaluechanged event add this code:
ds2.Clear()
da2.SelectCommand.Parameters("Project_Nbr").Value = cboField.SelectedValue
da2.Fill(ds2)
cboProjectSelect.Focus()

This will select whatever record from ds2 that matches whatever the user selected in the combo box. Of course you should change the names of the fields in this example to be meaningful to your application...

 
On the combobox properties.

Set the datasource to the lookup table
Set the Displaymember to the field looking up
Set the Value member to the field that gets carried to the new table

Set the databindings text to the table and field that gets the valuemember carried to.

After you get this working go to this link and download a better autocompletecombobox to use. (it fills in automatically when you start typing) There are lots of freeware comboboxes on the net that do a great job of sorting and autofilling.

There is a download at the bottom.
 
Thanks so much for getting back to me. I will work on this tonite.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top