Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required Error in Multi Select List Box Code 1

Status
Not open for further replies.

xweyer

MIS
Sep 7, 2000
140
US
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
 
How about:
varValue = Me.lst_Obj.Column(1, Item)
 
Thanks to both of you. I had taken the VB from a posting elsewhere and the syntax was apparently wrong.

Remou,
You had the right version. I just altered it slightly to varValue = Me.lst_Obj.Column(1) for my purposes and now I'm good to go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top