How to change the value of a listbox item

rockman

Senior Member
Local time
Today, 10:06
Joined
May 29, 2002
Messages
190
I can't find the answer to this simple question in the archives:

I have a listbox based on a "value list" (for example):
Red
Green
Purple

How do I change the second item to read "Yellow":
Red
Yellow
Purple

Thanks for any help,
Jeff
 
Use a table instead of values, its much easier to manage

Regardz
 
Go to the RowSource Field in the properties window for the listbox - you can simply over write the word green with yellow...

HTH,
Kev
 
Thanks for your responses:

Kevin_S - I should have made myself more clear. I was wanting to achieve the name changing via code so other (non-programming) users would be able to do it.

I was able to get this to work:
Code:
Private Sub cmdChangeName_Click()
Dim sList() As String
  sList = Split(lstList.RowSource, ";")
  sList(lstList.ListIndex) = txtNewItemName
  lstList.RowSource = Join(sList, ";")
End Sub
There is a limitation that users can't use a semicolon in their list. (Not a terrible restriction in my case).

namliam - Thanks for your post. It reminded me that even if I'm able to change the list item name, there is no guarantee that Access is going to permanently save the RowSource string changes. I'll take your advice and use a table.

Thanks all,
Jeff
 
Sometimes i make a Combobox/listbox table for "fixed" values of those boxes.

Then i number them, or give them names (a second field in the table). This limits the number of tables you need to 1 with the flexibility of changing it very easy. Even if you use the same combo many times.

Also you could add an order field, so you can order the list in any way you see fit.

Good luck on the project

Greetz
 

Users who are viewing this thread

Back
Top Bottom