dayiku
asked on
How can I pass multiple values with a combo box
I have a combo box setup on a vb form. I need to populate another combo box based on the value selected in the first one.
How can i pass the id of a record along with the name with a combo box?
This is part of my code that populates the combo box,
Dim cb As ComboBox
Set cb = Me.Controls(strComboName)
While Not recResult.EOF
cb.AddItem recResult.Fields(0)
recResult.MoveNext
Wend
In my program i can retrieve the value the user sees but i want to pass an id field along with every name displayed so i can use it to run another query.
Can somebody help with this?
How can i pass the id of a record along with the name with a combo box?
This is part of my code that populates the combo box,
Dim cb As ComboBox
Set cb = Me.Controls(strComboName)
While Not recResult.EOF
cb.AddItem recResult.Fields(0)
recResult.MoveNext
Wend
In my program i can retrieve the value the user sees but i want to pass an id field along with every name displayed so i can use it to run another query.
Can somebody help with this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the information.
I tried to retrieve the value but it only gives me the last entry. I want the current selected value.
How do i do that?
eg id =21343 Name=Dept1
id =21445 Name=Dept2
When the user selects Dept1 i want the id.
I tried to retrieve the value but it only gives me the last entry. I want the current selected value.
How do i do that?
eg id =21343 Name=Dept1
id =21445 Name=Dept2
When the user selects Dept1 i want the id.
ASKER
I just figured it out.
shijusn,
TO retrieve value it should be cb.ItemData(ListIndex)
Thanks.
shijusn,
TO retrieve value it should be cb.ItemData(ListIndex)
Thanks.
cb.ItemData(Index)