I have a simple form through which I'd like to be able to delete multiple tables. lst_Obj is the multi selection list box that contains the table listing. The second column of that list box holds the table names which I want to utilize in the deletion procedure.
The code below is attached to the "On Click" property of a Command Button intended to perform the deletion. When the button is clicked the error "Run-time error 424. Object required." with the line in red highlighted.
Any ideas as to where I've gone wrong?
Private Sub Cmd_ObjDelete_Click()
Dim db As DAO.Database ' DAO
Set db = CurrentDb()
Dim varItem As Variant
Dim varValue As Variant
For Each varItem In Me.lst_Obj.ItemsSelected
varValue = Me.lst_Obj.ItemData(varItem).Column(1)
DoCmd.DeleteObject acTable, varValue
Next varItem
End Sub
The code below is attached to the "On Click" property of a Command Button intended to perform the deletion. When the button is clicked the error "Run-time error 424. Object required." with the line in red highlighted.
Any ideas as to where I've gone wrong?
Private Sub Cmd_ObjDelete_Click()
Dim db As DAO.Database ' DAO
Set db = CurrentDb()
Dim varItem As Variant
Dim varValue As Variant
For Each varItem In Me.lst_Obj.ItemsSelected
varValue = Me.lst_Obj.ItemData(varItem).Column(1)
DoCmd.DeleteObject acTable, varValue
Next varItem
End Sub