Reputation: 49
i create a list box that show table records and a delete button in access form
i want when user select an item from list box and click on delete button
with SQL code delete related item that selected in list box
i find some code like this:
Dim strSQL As String
strSQL = "DELETE FROM Tbl_DCC WHERE Text_AgnetName = " & Me.List_DCC.Column(0) &" and "& Me.List_DCC.Column(2)
CurrentDb.Execute strSQL
Me.List_DCC.Requery
But it Does not work I am thankful with your guidance
Upvotes: 0
Views: 91
Reputation: 1577
try to put single quotes in the where clause
Dim strSQL As String
strSQL = "DELETE FROM Tbl_DCC WHERE Text_AgnetName = '" & Me.List_DCC.Column(0) &"' and '"& Me.List_DCC.Column(2) & "'"
CurrentDb.Execute strSQL
Me.List_DCC.Requery
Upvotes: 2