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.
Martin J. - 07 Nov 2007 11:59 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> 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
fredg - 07 Nov 2007 15:30 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> 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

Signature
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail