update list box selections into text box

  • Thread starter Thread starter c8tz
  • Start date Start date
C

c8tz

Hi,

I have a list box and a command button and a text box on a form. What
I would like to do is when selections are done from the list box, the
command button is used to update the selections into the text box.

Is this possible to do - Thank you for your assistance.
 
Hi,

I have a list box and a command button and a text box on a form. What
I would like to do is when selections are done from the list box, the
command button is used to update the selections into the text box.

Is this possible to do - Thank you for your assistance.


after clicking the command button the currently selected entry in the
listbox is written into the textbox. Is this what you wanted?

Private Sub MyCommandButton_Click()
MyTextBox.Value = MyListBox.Value
End Sub

Martin
 
Hi,

I have a list box and a command button and a text box on a form. What
I would like to do is when selections are done from the list box, the
command button is used to update the selections into the text box.

Is this possible to do - Thank you for your assistance.

I assume this is a MultiSelect list box, also that the control on the
form is unbound.
You can use a command button, but I would use the Exit event of the
list box.

Private Sub ListName_Exit(Cancel As Integer)
Dim varItem As Variant
For Each varItem In ListNamet.ItemsSelected
SomeControl = SomeControl & ListName.ItemData(varItem) & ", "
Next varItem
SomeControl = Left(SomeControl,Len(SomeControl)-2)
End Sub

The above will display as
Red, Green, Blue
 
Back
Top