Using a listbox/combo box to show two values
Hi there, I'm currently using a list box to display a single list of Manager names (defined on another sheet as 'Names') the listbox on_click subroutine stores the value of the list box into a text box for the user to see what they have selected. this text box value then gets passed into another subroutine that uses it in some SQL. On my defined range of names, I need to add a second column - manager_id. this must also be passed into the SQL subroutine, but I have no idea how to do this. it doesn't necessarily have to be displayed in the list box (or combo box, if more suited), but I need to pass both the name and the id into the SQL subroutine. can anyone give me some guidance with this? thanks, Matt -- matpj ------------------------------------------------------------------------ matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076 View this thread: http://www.excelforum.com/showthread...hreadid=512156 |
Using a listbox/combo box to show two values
When you load the listbox, either use a 2D array (Range(A1:B10), or if being
loaded singly, do so like this With lstManagers .AddItem hisName .List(.ListCount-1,1) = hisId .etc End With obviously you will need to add the values To get it back you simply use hisName = lstManagers.Value hisId = lstManagers.List(lstManagers.ListIndex, 1) By not setting the ColumnCount property of the listbox, the id will not be displayed. -- HTH Bob Phillips (remove nothere from email address if mailing direct) "matpj" wrote in message ... Hi there, I'm currently using a list box to display a single list of Manager names (defined on another sheet as 'Names') the listbox on_click subroutine stores the value of the list box into a text box for the user to see what they have selected. this text box value then gets passed into another subroutine that uses it in some SQL. On my defined range of names, I need to add a second column - manager_id. this must also be passed into the SQL subroutine, but I have no idea how to do this. it doesn't necessarily have to be displayed in the list box (or combo box, if more suited), but I need to pass both the name and the id into the SQL subroutine. can anyone give me some guidance with this? thanks, Matt -- matpj ------------------------------------------------------------------------ matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076 View this thread: http://www.excelforum.com/showthread...hreadid=512156 |
All times are GMT +1. The time now is 01:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com