Results 1 to 2 of 2
  1. #1
    thart21 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    83

    Multi select list box and DELETE query

    I am attemtping to run a query from my command button that will delete the selected records that match the recordid(s) selected in a listbox.

    I keep getting an "object required" error at "Set ctl = Me.lstCurrent.Column(1)

    Dim db As DAO.Database


    Dim ctl As Control
    Dim varItem As Variant

    Set db = CurrentDB()
    Set ctl = Me.lstCurrent.Column(1)

    For Each varItem In ctl.ItemsSelected
    CurrentDB.Execute "DELETE * FROM tblSpecialty_by_SME WHERE recordid = " & ctl.ItemData(varItem)
    Next varItem
    Forms!frmSpec.Requery

    Any ideas for how I could do this differently?

    Thanks!

    Toni

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The line with the error should simply be:

    Set ctl = Me.lstCurrent

    and then get the column in your SQL:

    ctl.Column(1, varItem)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 09-22-2011, 01:13 PM
  2. Multi-Select List Box as Criteria in Query
    By broadwat in forum Queries
    Replies: 6
    Last Post: 09-19-2011, 07:47 AM
  3. Multi select list box
    By foxtet in forum Forms
    Replies: 1
    Last Post: 05-30-2011, 02:13 PM
  4. Replies: 1
    Last Post: 01-28-2011, 07:59 PM
  5. Replies: 1
    Last Post: 10-22-2010, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums