Changing Text in Listbox

Y

y770

I have an unbound Listbox whose source is a Value List.
I need to update a value in one of the columns in selected row based on the
value of another TextBox.
It would make sence to simply state: Me.lstBox.Column(2) = Me.txtBox
but Column property is Read-Only and you cannot assign value to it.:-(
Is there a simple way to do it other then redefine the whole RowSource?

y770
 
K

Klatuu

Look in VBA help for the AddItem and RemoveItem methods. It explains how to
do this and has some decent examples.
 
M

Marshall Barton

y770 said:
I have an unbound Listbox whose source is a Value List.
I need to update a value in one of the columns in selected row based on the
value of another TextBox.
It would make sence to simply state: Me.lstBox.Column(2) = Me.txtBox
but Column property is Read-Only and you cannot assign value to it.:-(
Is there a simple way to do it other then redefine the whole RowSource?


No, not that I ever heard of.
 
M

Marshall Barton

Klatuu said:
Look in VBA help for the AddItem and RemoveItem methods. It explains how to
do this and has some decent examples.


Sheesh, when did RemoveItem show up?

I guess it's been a loooonng time since I used a Value List
:-\
 
S

Stuart McCall

y770 said:
I have an unbound Listbox whose source is a Value List.
I need to update a value in one of the columns in selected row based on
the
value of another TextBox.
It would make sence to simply state: Me.lstBox.Column(2) = Me.txtBox
but Column property is Read-Only and you cannot assign value to it.:-(
Is there a simple way to do it other then redefine the whole RowSource?

y770

Another way to do it:

Dim a As Variant

a = Split(Me.lstBox.RowSource, ";")
a(2) = Me.txtBox
Me.lstBox.RowSource = Join(a, ";")
 

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

Similar Threads


Top