?
Solved

remove button to remove item from listbox

Posted on 2011-05-06
3
Medium Priority
?
313 Views
Last Modified: 2012-05-11
Hello,
I have a remove button problem - to remove item from listbox- it does remove from listbox visually-
but when I add record to database- the removed item is there with other items

the database is attached- open- form comes up-  
enter service#-select name- enter 2 part numbers - try to select part number and use remove button-
you will see it looks like removes but does not.

am using:
If Me.lstPartsUsed <> -1 Then
 Me.lstPartsUsed.RemoveItem Me.lstPartsUsed.ListIndex
Else
  MsgBox "Select an item to remove"
End If
thank you
remove-button-db.mdb
0
Comment
Question by:davetough
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 35706804
A list box has a RowSource (that feeds the listbox)
If you want to *really* remove an item form a listbox, you must remove it from the Row source.

This does not necesarilly mean that you must delete the item form the table....
If the listbox is based on a query you can simply add a "Removed" Yes/No field to the table.
Then set this to yes or no depending on if you want the item seen or not.

If this case the source for yor listbox will be something like this:
SELECT fld1, fld2, Removed
FROM YourTable
WHERE Removed=False

JeffCoachman
0
 

Author Closing Comment

by:davetough
ID: 35706964
thanks
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35707216
;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question