Multiselect listbox - delete an item

GetReel

Registered User.
Local time
Today, 21:02
Joined
May 22, 2003
Messages
67
I have multiselect list box that hold emails addresses for contractors.

There will times when an email address maybe obsolete therefore I need delete it. Ive search the forum on how to delete the selected item but I could find anything.

I would like to delete the selected item via button on the form.
 
You mean you want to delete an item from the multiselect listbox? How is the listbox populated? Is it based on a table/query or on a SQL string, or value list?
 
Yep! delete an item. The list box is populated via Table/Query
 
If an e-mail address no longer pertains, then you should really worry first about removing it from the underlying query that feeds the listbox. If you delete the e-mail address from the query while the multiselect listbox is open, you'll need to requery the listbox to have it show the most current data. Just do a Me.listbox1.Requery.

If you want to continue basing your listbox rowsource on a query, but just want to remove the display of certain data (but not remove it from the underlying query), then you'll have to work it very differently.
 
I think I will go with Me.lstEmail.requery but how do I delete the selected email address via the listbox and delete it.
Should use something like this to delete the email address via a form:
DoCmd.Openform "frmEmails", , , "[EmailID] = " & lstFound.Column(0)
Me![lstEmail] = ""


CmdDeleteEmail_OnClick
forms!frmEmailSelect!lstEmail.requery

Is this logical way of doing it.
 
Are you sure you mean a multiselect listbox? If it's a single-select listbox, then code like:
Me.[lstEmail]
will get you the selected value.

The way to get to the 1st selected item in a multiselect list box is:
Me.lstEmail.ItemData(Me.lstEmail.ItemsSelected(0))

Once you have the value of the selected item, you can then move onto deleting it from the underlying data.
 
Im just not getting it. Ive attached a strip down version of the list box.

Im using the multiselect list box which allow me to selected multiple addresses is so that I can send the address to lotus notes at a later stage.
 

Attachments

Users who are viewing this thread

Back
Top Bottom