Results 1 to 8 of 8
  1. #1
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85

    Delete multiple selections

    Hey guys, its good to be back to this forum

    Here is my piece of code that deletes selected Building, question is: how can i make it deleted several selected building? Thanks in advance


    Private Sub cmd_DeleteBuilding_Click()

    Dim Answer As String

    If IsNull(Me.Building__Subform.Form.BuildingID) Then

    MsgBox ("Please select a building")



    Exit Sub

    End If

    Answer = MsgBox("Delete Building?", vbQuestion + vbYesNo, "Confirm")

    Select Case Answer

    Case vbYes

    CurrentDb.Execute "Delete * From Building Where BuildingID = " & Me.Building__Subform.Form.BuildingID

    DoCmd.Requery

    Case vbNo

    Exit Sub

    End Select

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You could use a multiselect listbox, and delete each item the same way you are within a loop of the selected items.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    sory, i have been out of access development for 3 - 4 months, could you explain bit further, my brain is still bit raw heheh

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This type of thing, but with your delete SQL instead of the recordset lines.

    http://www.baldyweb.com/MultiselectAppend.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    thank you, will give it go

  6. #6
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    oh... looks bit complex for my vba haha, if you ever have a min could you fill me into the details bit more

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Sorry, I lost track of this thread. Did you get it sorted out?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    DaveT is offline Access Developer
    Windows 7 Access 2010 (version 14.0)
    Join Date
    May 2010
    Location
    Texas
    Posts
    69
    I think this only works for using recordselect for adjacent records, but is a way to select multiple records and enumerate (list) them in code.

    How to enumerate selected form records in Access 2003 and in Access 2002
    http://support.microsoft.com/kb/294202

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

Similar Threads

  1. Replies: 3
    Last Post: 05-25-2010, 02:16 PM
  2. Replies: 0
    Last Post: 04-08-2010, 12:22 PM
  3. Replies: 5
    Last Post: 12-10-2009, 10:33 PM
  4. Replies: 1
    Last Post: 12-10-2009, 08:41 PM
  5. Replies: 1
    Last Post: 03-02-2009, 11:54 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