Using a listbox/combo box to show two values

  • Thread starter Thread starter matpj
  • Start date Start date
M

matpj

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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top