Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2002
    Location
    Maidenhead, UK
    Posts
    2

    Unanswered: List Box in Access 97

    Is it possible to pass the (multiple) selection(s) in a list box to a query, so that an update can be caried out using the chosed values in the criteria?

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Sure.

    It involves a little coding, but it's not too bad.

    Here's an example of code which will fill a table which you can use in a query, joined on the ID field, to do what you want.

    Your list box must have it's multiselect property set to extended.

    Code:
        Dim rs As Recordset
        Dim ctl As Control
        Dim Item As Variant
    
        Set rs = CurrentDb().OpenRecordset("tblInclude")
        Set ctl = Forms![frmInclude]![IncludeList]
        
        DoCmd.SetWarnings False
        DoCmd.RunSQL("DELETE * FROM tblInclude")
        DoCmd.SetWarnings True
        
        For Each Item In ctl.ItemsSelected
            rs.AddNew
            rs!ID = CLng(ctl.ItemData(Item))
            rs.Update
        Next Item
        
        rs.Close
        Set rs = Nothing
        Set ctl = Nothing

  3. #3
    Join Date
    Mar 2002
    Location
    Maidenhead, UK
    Posts
    2
    Thanks PP, I think I understand (it's been a while since I programmed in Access!).

    I'll give it a go tomorrow.

    Pietro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •