Delete item from listbox (1 Viewer)

jegenes

Registered User.
Local time
Today, 15:50
Joined
Aug 25, 2001
Messages
19
Haven't been able to dig up the answer to this, so I'll break down and ask it here.

How do you go about deleting an item in a listbox, and then have the listbox update itself. In VB you can just removeitem the item in the array. Access doesn't seem to support this.

Also, please note that it's a 4-column listbox and I want to be able to remove the entire row, any selected rows (usually, one at a time).

Thanks very much.

John Egenes

[This message has been edited by jegenes (edited 08-31-2001).]

[This message has been edited by jegenes (edited 08-31-2001).]
 

R. Hicks

AWF VIP
Local time
Yesterday, 22:50
Joined
Dec 23, 1999
Messages
619
Hmmm .... never really thought about this.

What if the choice you want to remove is referentually connected to an existing record? This will cause problems.

RDH
 

jegenes

Registered User.
Local time
Today, 15:50
Joined
Aug 25, 2001
Messages
19
>>>What if the choice you want to remove is referentually connected to an existing record? This will cause problems. <<<

Here's what I'm doing:

I've got a combobox with 4 columns, which gets its rowsource from a query. This works fine, and gives a list of items to choose from. The user can choose one or more items and, by clicking an "add" button, they'll be copied into the listbox. The listbox code is written such that it won't allow more than one copy of an item in its array.

So, if the user makes a mistake and sends the wrong item over to the listbox, I want to allow them to undo it.

The only thing I can think of is this:

I make another, hidden, listbox. When the user clicks a "remove" button it causes an event procedure. This copies everything EXCEPT the items selected from the listbox into the hidden listbox.
Then (in the code) it copies the hidden box's contents back into the first listbox. Of course, I'd first have to have it issue a command like, lstBox.RowSource = "" or something so that the listbox would clear itself, and then be filled back up (without the "selected" rows.
This sounds a bit convoluted, and I was hoping there'd be an easier way to do it. I don't think that deleting an item from the listbox will in any way affect my tables, etc.

Thanks

John

[This message has been edited by jegenes (edited 08-31-2001).]
 

R. Hicks

AWF VIP
Local time
Yesterday, 22:50
Joined
Dec 23, 1999
Messages
619
I see what you are attempting to do. I have a sample db that is in Access 97 that uses this basic idea but it used two listboxes instead of a combo and a listbox. The principle should be the same. If you would like a copy of this to look at, I will email you a copy. Just let me know.

Once the choice is made in one, it moves the choice to the other and then removes the choice from the first. This would stop duplicate entries. Right and Left buttons w/arrows between the two does the work.

HTH
RDH

[This message has been edited by R. Hicks (edited 08-31-2001).]
 

jegenes

Registered User.
Local time
Today, 15:50
Joined
Aug 25, 2001
Messages
19
Yes, I would love a copy of that code. The R-L button idea is a good one. Exactly what I want. I'm really surprised that this isn't just a plug-in piece of code, that you could set up with the wizard. Seems like a pretty common application to me.

Oh, and I should have said that I DO have 2 listboxes (not a combobox). I had started out with a combobox, then changed it to a listbox because it was easier for the user.

Email: johnegenes@compuserve.com

Thanks very much

Best,

John

[This message has been edited by jegenes (edited 08-31-2001).]
 

R. Hicks

AWF VIP
Local time
Yesterday, 22:50
Joined
Dec 23, 1999
Messages
619
Headed your way .... hope it helps you.

RDH
 

Users who are viewing this thread

Top Bottom