M
mo
A listbox on a form has the following code which is meant to delete only the
seelcted items from the underlying table, but instead deletes all the
records in the listbox (anf the table). Can anyone see what I'm doing wrong?
Thanks for any help.
Dim db As DAO.Database
Dim strSQL As String
Dim strWhere As String
Dim varSelected As Variant
For Each varItem In Me.lst_selected.ItemsSelected
strWhere = "HospNum = " & "'" & Me.lst_selected.ItemData(varSelected) &
"'"
Next varItem
strSQL = "DELETE * FROM tbl_Lists "
strSQL = strSQL & "WHERE " & strWhere
'Debug.Print strSQL
Set db = CurrentDb()
db.Execute strSQL
Me.list_main.Requery
Set db = Nothing
seelcted items from the underlying table, but instead deletes all the
records in the listbox (anf the table). Can anyone see what I'm doing wrong?
Thanks for any help.
Dim db As DAO.Database
Dim strSQL As String
Dim strWhere As String
Dim varSelected As Variant
For Each varItem In Me.lst_selected.ItemsSelected
strWhere = "HospNum = " & "'" & Me.lst_selected.ItemData(varSelected) &
"'"
Next varItem
strSQL = "DELETE * FROM tbl_Lists "
strSQL = strSQL & "WHERE " & strWhere
'Debug.Print strSQL
Set db = CurrentDb()
db.Execute strSQL
Me.list_main.Requery
Set db = Nothing