Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

Delete from a listbox.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James - 28 Apr 2005 04:28 GMT
How do you delete an item from a listbox?
Allen Browne - 28 Apr 2005 07:52 GMT
Change the WHERE clause in the listbox's RowSource.

This example shows how to exclude agencies 5 and 6 from the list box:

Me.[List0].RowSource  = "SELECT AgencyId, AgencyName FROM tblAgency WHERE
AgencyId NOT IN (5, 6) ORDER BY AgencyName;"

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> How do you delete an item from a listbox?
Dennis - 28 Apr 2005 09:06 GMT
if your listbox is based on table values then you can delete from the table
and then requery your listbox
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM TableName WHERE FieldName = '" &
ListBox.Column(0, ListBox.ListIndex) & "'"
ListBox.Requery
DoCmd.SetWarnings True

> How do you delete an item from a listbox?
James - 28 Apr 2005 15:02 GMT
Thank you for your help.  It loooks like it is trying to work but I get an
error: "Data type mismatch in criteria expresion"

The field in the table is an autonumber field.  Is that a problem and how do
I fix it?

> if your listbox is based on table values then you can delete from the table
> and then requery your listbox
[quoted text clipped - 5 lines]
>
> > How do you delete an item from a listbox?
Dennis - 28 Apr 2005 15:08 GMT
If the item in the listbox and table is numeric instead of text then change
the 1 line to
DoCmd.RunSQL "DELETE * FROM TableName WHERE FieldName = " &
ListBox.Column(0, ListBox.ListIndex)

> Thank you for your help.  It loooks like it is trying to work but I get an
> error: "Data type mismatch in criteria expresion"
[quoted text clipped - 11 lines]
> >
> > > How do you delete an item from a listbox?
James - 28 Apr 2005 15:02 GMT
Thank you for your help.  It loooks like it is trying to work but I get an
error: "Data type mismatch in criteria expresion"

The field in the table is an autonumber field.  Is that a problem and how do
I fix it?

> if your listbox is based on table values then you can delete from the table
> and then requery your listbox
[quoted text clipped - 5 lines]
>
> > How do you delete an item from a listbox?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.