Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012

    Unanswered: Multiple Selections in a ListBox.....

    I have 2 ListBoxes on my form ErrorCodeDescription and ErrorCodesandCorrections in Access 2007. I created 2 Tables and Query for these as well ErrorCodeDescription/Tiger Table/Tiger Query and for ErrorCodesandCorrections/Error Codes and Corrections Table/Error Codes and Corrections Query. The problem that I am having is both of these are ListBoxes and information is populated by both of these boxes from the queries stated above.

    I want the user to be able to select several choices in both boxes and that information to be saved in another table. The problem I am having is when I only select one option everything works just fine however when I select 2,3,4 option nothing show up in my database. I was told that I may have to write some VB code on the back end however I am a green when it comes to VB and I need some assistance. Can anyone give me some help out there.

    And did i mention I am very new to this as well and a Screen Shot is attached as well.....
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 14
    When a list has its MultiSelect property set to 1 (Simple) or 2 (Extended), you can retrieve the data of every selected row using the ItemsSelected collection of the list. Depending on whether you want to retrieve the data from the bound column only or from every column, the code to be used varies slightly. In the following example that illustrates both techniques, <List Name> is a placeholder for the name of the list:
    ' Retrieve the data from the bound column of a list
    ' (MultiSelect = 1 or 2) for every selected row.
        Dim varItem As Variant
        For Each varItem In Me.<List Name>.ItemsSelected
            Debug.Print Me.<List Name>.ItemData(varItem)
        Next varItem
    ' Retrieve the data from every column of a list
    ' (MultiSelect = 1 or 2) for every selected row.
        Dim varItem As Variant
        Dim i As Integer
        For Each varItem In Me.List0.ItemsSelected
            For i = 0 To Me.<List Name>.ColumnCount - 1
                Debug.Print Me.<List Name>.Column(i, varItem)
            Next i
        Next varItem
    Have a nice day!

Posting Permissions

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