update list box selections into text box

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.
 
M

Martin J.

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
 
F

fredg

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
 

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

Top