Hi Tom,
Thank you for using MSDN Newsgroup! It's my pleasure to assist you with this issue.
From your description, I understand that you wanted to delete the highlighted record within teh
list box on the form. Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.
I'm not sure of your Access version and I think the following method may be all-purpose in
Access 2000 and Access 2002. This method is deleting the records in the Products table so
you should backup the database first. Please also make sure that there is no Primary Key
violation when you delete the record in the table, otherwise, the deletion will be avoided.
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command2_Click()
Dim strSQL As String
If Not IsNull(List0) Then
strSQL = "Delete * From Products Where ProductID=" & Me.List0.Value
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Me.List0.Requery
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
In Access 2002 or later, you can use RemoveItem to delete the highlighted record in your list
box.
For how to move the items between the list box, please reference the following articles:
177117 ACC: How to Move List Box Items to Another List Box (7.0/97)
http://support.microsoft.com/?id=177117
278378 How to Use AddItem and RemoveItem to Move Selections from One List Box
http://support.microsoft.com/?id=278378
Does that answer your question? Please apply my suggestions above and let me know if this
helps resolve your problem. If there is anything more I can do to assist you, please feel free to
post it in the group.
Best regards,
Billy Yao
Microsoft Online Support