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 / New Users / December 2004

Tip: Looking for answers? Try searching our database.

delete ListBox Row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 30 Dec 2004 11:42 GMT
How would I select a listbox row and Delete that row from a list box? (Using
a command button)
John Nurick - 30 Dec 2004 18:20 GMT
Hi Chris,

This depends on what the rowsource of the listbox is.

If it's a table or query, you need to write VBA code that deletes the
corresponding record from the underlying table.

If it's a value list, you need to write code that deletes the
corresponding entry from the string that makes up the list.

>How would I select a listbox row and Delete that row from a list box? (Using
>a command button)

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Chris - 30 Dec 2004 18:46 GMT
It's based on a query.

I'm sure I've done it with a  "DoCmd" command (linking with the ID id the
listBox)

However I can't remember how to do that and have tried using
the recordset to delete the record.  Again I just can't figure it out

Please Help me before New Year

> Hi Chris,
>
[quoted text clipped - 13 lines]
>
> Please respond in the newgroup and not by email.
John Nurick - 30 Dec 2004 22:15 GMT
Something like this air code should do it:

Dim strSQL As String

strSQL = "DELETE * FROM MyTable WHERE KeyField=""" _
 & Me.lbXXX.Value & """;"
CurrentDB.Execute strSQL
Me.lbXXX.Requery

You'll need to replace
    MyTable with the name of the table
    KeyField with the name of the field in the table corresponding
     to the bound column in the listbox
    lbXXX with the name of the listbox (*not* the name of the field
     the listbox is bound to).

>It's based on a query.
>
[quoted text clipped - 24 lines]
>>
>> Please respond in the newgroup and not by email.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
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.