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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Value in Combo 1

Status
Not open for further replies.

niall29

Technical User
May 1, 2003
38
GB
Hi
I know there has to be a better way of doing this and hopefully someone knows it.
but here goes,
I have a combobox populating from a SQL table which has 2 columns (User_ID and User_Name). I am populating the combo box with User_Name then when you pick the appropiate name it should look at another table to get their records but it needs the User_ID to do this.
In VB6 I used to make another combo box populated by the User_ID which was hidden and when you picked a User Name then the User_ID combo would change to the relevant ID.
but I am sure there has to be a better way of doing this.
any help would be highly appreciated.
 
Use valuemember to hold your user id, and displaymember to hold the user_name. Then use the combos selectedvalue property to get back your user_id



Sweep
...if it works dont mess with it
 
Dim UID As Integer
UID = Ctype(MyCombo.Items(MyCombo.SelectedIndex), DataRowView).Item("User_ID")
 
Another option...check out this thread by Chiph - it's C# but nothing complicated. It makes use of the combo items being objects.

thread732-949121
 
Thanks for your help all of you.
but I went with SqueakinSweep's idea.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top