473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Edit item value in an unbound list box

759 512MB
Hello !
Please, be patient with me :) but I spend 2 hours to find a way to do that with no success.

So:
I have an unbound list box. Only one column.
I fill this list using .AddItem command.
Now I wish to modify the value for item(n).

Oh, of course I can remove this item then insert other one in the same position (index) in the list with the new value.

But... is no solution to edit that item ?

Thank you !
Mar 19 '12 #1
3 13700
NeoPa
32,556 Expert Mod 16PB
Very interesting question.

Unfortunately, I believe the answer is "No". .Itemdata(), which might otherwise have been a viable approach, is a ReadOnly property, and I can find no other approach that might work (other than the obvious one of removing then re-adding the entry of course).
Mar 19 '12 #2
Mihail
759 512MB
Because I can't find a solution to directly edit that damned item, I have developed a piece of code to do that:
Expand|Select|Wrap|Line Numbers
  1. Private Function ModifyItemInList(LstBx As ListBox, NewValue As String, R As Long, Optional C As Long = 0) As Boolean
  2. 'C > 0 is used for multicolumns list boxes
  3. On Error GoTo Ex
  4.     ModifyItemInList = False
  5. Dim SplitedRowSource
  6.     SplitedRowSource = Split(LstBx.RowSource, ";")
  7.     'Modify item
  8.     SplitedRowSource(R * LstBx.ColumnCount + C) = NewValue
  9. 'Create the new RowSource
  10. Dim NewRowSource As String, i As Long
  11.     For i = 0 To UBound(SplitedRowSource)
  12.         NewRowSource = NewRowSource & SplitedRowSource(i) & ";"
  13.     Next i
  14.     'Remove last ";"
  15.     NewRowSource = Left(NewRowSource, Len(NewRowSource) - 1)
  16.     'Update
  17.     LstBx.RowSource = NewRowSource
  18.  
  19.     ModifyItemInList = True
  20. Exit Function
  21.  
  22. Ex:
  23.     ModifyItemInList = False
  24. End Function
But more questions has been raised in this time.
So please take a look to this thread:
http://bytes.com/topic/access/answer...oo#post3711825
Mar 26 '12 #3
NeoPa
32,556 Expert Mod 16PB
I suggest you use the simpler method of romoving and adding the item using .RemoveItem() and .AddItem() now it's clear how that can work (See linked thread).
Mar 26 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Yazeed | last post by:
im adding a Calendar using a template withing a datagrid in edit item template, how can i access the value of the selected date? or where to handle the event SelectedDateChanged ?
3
by: jason | last post by:
I know I have seen this somewhere but I can't seem to find it. I would like to add the list item value along with my list item text. So far I have this: Listbox1.Items.Insert("0", "All") ...
0
by: Adam Knight | last post by:
Hi all, I have two nested DataLists. When I click edit in the parent list the edit comand executes and the required Edit Item Template is displayed. The child list is display in the...
5
by: Joe Fallon | last post by:
I have a list box with 7 text values in it. I have a pair of buttons to Move Up or Move Down the selected item one position. What is the simplest way to code the buttons so the item moves one...
1
by: ApexData | last post by:
WatchOut for "Allow AutoCorrect" in your unbound combobox lookups. I am building a personnel database, and the last name of Ballance was causing the following message to popup, prohibiting me from...
5
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, how to edit item in the comboBox in main form afetr start run app? Thanks, Martin
1
gcoaster
by: gcoaster | last post by:
Hello Group, I was wondering if anyone out there can help me I have a form Unbound List Box Control on the form The row source is a built-in query. I was wondering if there is anyway to...
1
by: rogerford | last post by:
I have a grid which i bind with values from Database. I have events to edit and update the grid. I am not using SqlDatasource to connect to DB. Rather i am doing the updating of the grid...
2
by: Steve | last post by:
I am working on a program that works like a check in/check out system. There is a folder on a network drive that stores a bunch of vb programs. This program will check in and check out programs...
6
by: AdamOnAccess | last post by:
Hi, I need to store the last value of an unbound list box. For example, if the list box is currently set to X, when a user clicks Y, I need to save X in a variable. I've tried to store the old...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.