delete from value list

supmktg

Registered User.
Local time
Today, 17:47
Joined
Mar 25, 2002
Messages
360
I'm trying to delete a selected single row from a list box with a value list rowsource. Each row in the value list has 4 columns, and I need to remove the entire row.

I tried to use Me.lstPrepaid.removeitem. Intellisense isn't recognising removeitem and I'm getting a compile error 'method or data member not found'.

Any advice would be appreciated.
Thanks,
Sup
 
If your listbox is based on a table, remove the record from the table and requery the listbox.

HTH
 
The problem is, my listbox isn't based on a table. It is a value list created on the fly by the user.

I guess I could change the value list to a temp table, but I'm sure there is a way to delete a row from a value list. If anyone has a simple way to do it I'd really appreciate it.

Thanks,
Sup
 
A value list rowsource is a simple string. If you know the exact text of the data you want to remove from a string you can use the Replace() function.
Without consulting any references I'd guess the syntax is...
Code:
Replace(<OrigString>, <SubStringToReplace>, <StringToReplaceItWith>)
For your rowsource issue, it'll look like this...
Code:
Me.List.RowSource = Replace(Me.List.RowSource, "123;John;Doe;01/12/1970;", "")
 
Lagbolt,

Thank you! I knew there was a simple solution.

I appreciate your help,
Sup
 
I took a look at this. The removeitem method was available to me and intellisense prompted it too (using VB 6.3).

Did you try it without relying on intellisense (note the index at the end)

Me.lstPrepaid.removeitem 1

I could only replicate the error by either using an incorrect object name or using an object name that wasn't a list box. So double check your names and object types. Occasionally I've made the mistake of using the label name rather than the control name :o

Anyway, if Lagbolt's method does the trick then job done.

Chris
 
can you help me Please. Upload your file for me.
i want look your code and idea.
i will modify your code for develop my code .
Thank you very much.
 
kvang,

Because my listbox had multiple columns, I found it easier to use a table rather than a value list as the source of my listbox. I've attached a simple example of deleting an item from a listbox based on a table.

I hope this helps you,
Sup
 

Attachments

Thank you very much for your file.
i try to modify your code but it can't delete field in item.
how i do mistake?
can you look my file. in from1
tell me pls. What i do mistake.

Thank you anyone for help me.
 

Attachments

I'm not at a computer that has Access installed. Copy and paste your code into your reply, and I will see if I can help.

Are you using a value list or a table as the source of your listbox?
The example that I sent deletes the record from the source table. It will not work with a value list.

Sup
 

Users who are viewing this thread

Back
Top Bottom