I have an unbound list box with two columns. It lists the records in a table called tblBuilding. I use this list box in a form to add or delete records from the table.
The problem I am having is with deleteing records. I can get it to work fine if I only have one column in my list box, but with two columns it won't work. I'm pretty sure the problem is with the vba behind the 'delete' button;
I'm betting the problem is in the line beginning 'strSQL' in that I haven't defined the fields in the table properly, but to be honest I'm not sure of the correct syntax. Can anyone point me in the right direction?
The problem I am having is with deleteing records. I can get it to work fine if I only have one column in my list box, but with two columns it won't work. I'm pretty sure the problem is with the vba behind the 'delete' button;
Code:
Private Sub BTNDelete_Click()
On Error GoTo PROC_ERR
strSQL = "DELETE * FROM [tblBuilding] WHERE " & _
"[fldBuildingId] = """ & Me.ItemList & """;"
DoCmd.RunSQL strSQL
Me.ItemList.Requery
PROC_EXIT:
Exit Sub
PROC_ERR:
If Err.Number = 2501 Then
Else
End If
Resume PROC_EXIT
End Sub
I'm betting the problem is in the line beginning 'strSQL' in that I haven't defined the fields in the table properly, but to be honest I'm not sure of the correct syntax. Can anyone point me in the right direction?