Hi everyone!
I have a listbox with a rowsource of tVendors. The list of vendors needs to be trimmed sometimes so I need to delete some of the records. I have a delete command button on the form that runs the following code. My question is how I insert the item selected into the code- (!VendorID=?). And I assume that if I have multiple items selected that I could nest this code in a loop?
Private Sub cmdDelete_Click()
On Error GoTo ErrDelete
Dim strSQL As String
Dim rst As Recordset
Dim dbs As Database
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tVendors", dbOpenDynaset)
With rst
.Delete
!VendorID = lstVendors.ItemData???
.Update
.Close
End With
ExitDelete:
Exit Sub
ErrDelete:
MsgBox Err.Description
Resume ExitDelete
End Sub
Thanks for the help! These forums are GREAT!
GLGCAG
I have a listbox with a rowsource of tVendors. The list of vendors needs to be trimmed sometimes so I need to delete some of the records. I have a delete command button on the form that runs the following code. My question is how I insert the item selected into the code- (!VendorID=?). And I assume that if I have multiple items selected that I could nest this code in a loop?
Private Sub cmdDelete_Click()
On Error GoTo ErrDelete
Dim strSQL As String
Dim rst As Recordset
Dim dbs As Database
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tVendors", dbOpenDynaset)
With rst
.Delete
!VendorID = lstVendors.ItemData???
.Update
.Close
End With
ExitDelete:
Exit Sub
ErrDelete:
MsgBox Err.Description
Resume ExitDelete
End Sub
Thanks for the help! These forums are GREAT!
GLGCAG