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!

Pass a value from a combo box to a list

Status
Not open for further replies.

MattBeas

Programmer
Nov 15, 2001
17
GB
Hi!
I want to be able to pass value(s) from a combo box to a list box in order to create a list of items. Is this possible? Does anyone have a solution to this?
Any help would be greatly appreciated.
Thanks
 
Hi,

Try this
Put this code in the click event of your combobox

Private Sub Combo1_Click()
List1.AddItem Combo1.Text
End Sub

Hope this helps
Good luck
 
MattBeas,

The following works in '97.
Code:
Private Sub Combo9_Change()
Dim strList As String
If List7.RowSource = "" Then
strList = Combo9
Else
strList = List7.RowSource & "; " & Combo9
End If
List7.RowSource = strList
End Sub
List7 is unbound with its RowSource Type set to 'Value List'.

Consider a button to reset it as well.
Code:
List7.RowSource = "".


HTH



John

Use what you have,
Learn what you can,
Create what you need.
 
Hi,
I have tried the suggestions given but they don't seem to work. Does anyone have any other solutions??
Any help would be greatly appreciated.
Thanks
 
hi MattBeas,

I want to know if you are coding in visul basic6.0 ar if you are working in Access.
 
guess it depends on the Row Source Type for the ListBox, if it is a Value List then this will work.
Where cbo1 is the ComboBox and lst1 is the ListBox, and this example passes 2 columns to the ListBox

Private Sub cbo1_AfterUpdate()
If lst1.RowSource = "" Then
lst1.RowSource = cbo1.Column(0) & " " & cbo1.Column(1)
Else
lst1.RowSource = lst1.RowSource & ";" & cbo1.Column(0) & " " & cbo1.Column(1)
End If
lst1.Requery
End Sub

If the Row Source Type is Table/Query, then you have to Append the Data from the ComboBox to the Table that is used for the Query and/or ListBox.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top