I want to delete items selected from a list box in my form.
I have a piece of code that worked well in another form and tried to make it work here, but it isn't working.
I get the following error message "You can't assign a value to this object"
Am I missing something really simple?
Private Sub btnDelete_Click()
Dim frm As Form
Dim ctl As Control
Dim db As DAO.Database
Dim strsql As String
Dim i As Variant
Set frm = Forms("frm_SubTaskOrders")
Set ctl = frm![lstSubTaskOrders]
Set db = CurrentDb
For Each i In ctl.ItemsSelected
strsql = "DELETE FROM SubTaskOrders WHERE"
[STOid] = " & ctl.Column(0, i)" & " AND [STONo] = " & ctl.Column(1, i) & " AND [STOName] = " & ctl.Column(2, i) & " And [Toid] = " & ctl.Column(3, i)
db.Execute strsql, dbFailOnError
CurrentDb.Execute strsql, dbFailOnError