• MultiSelect Listbox (A2k)

    Author
    Topic
    #382921

    Hi,
    I have a listbox (with city, st. info) with its Multi Select set to extended. The listbox gets its data from a stored query.
    Most of the time there are 15 to 20 rows of data in the listbox.
    After making your multiple selections and clicking on a command button the records are processed and the ones selected are marked in the table as being processed.
    The listbox is then requeried and the previous selections no longer show up in the listbox. This part works as intended.
    The problem I’m having is that if I select more than 6 items, the rows still process ok, but the listbox still shows items highlighted, even after the Requery of the listbox in the code.
    You have to click a few times on different rows to get the highlighted rows to unselect. This part to is erratic sometimes clicking on a row to try to unselect 3 or 5 rows will highlight.
    Here is the code behind the process button:
    Dim strSQL As String
    Dim strACCT As String
    Dim strST As String
    Dim Ctl As Control
    Dim frm As Form
    Dim Item As Variant

    If Me.lstASSIGNED.ItemsSelected.Count = 0 Then
    MsgBox “You didn’t select anything”, vbInformation
    Exit Sub
    End If
    DoCmd.SetWarnings False

    Set frm = [Forms]![frmREGION_ASSIGN]
    Set Ctl = frm![lstASSIGNED]
    If Ctl.ItemsSelected.Count 0 Then
    For Each Item In Me.lstASSIGNED.ItemsSelected
    strACCT = Me.lstASSIGNED.Column(0, Item)
    strST = Me.lstASSIGNED.Column(4, Item)

    strSQL = “DELETE tblREGION_ASSIGNMENTS.* ” & _
    “FROM tblREGION_ASSIGNMENTS ” & _
    “WHERE (((tblREGION_ASSIGNMENTS.ACCT_NUMBER)= ” & “””” & strACCT & “””” & “));”
    DoCmd.RunSQL strSQL ‘UNASSIGNES THE SSM

    DoCmd.RunSQL “UPDATE tblDEALERS SET tblDEALERS.ASSIGNED = FALSE ” & _
    “WHERE (((tblDEALERS.ACCT_NUMBER)= ” & “””” & strACCT & “””” & “) ” & _
    “AND ((tblDEALERS.ST)= ” & “””” & strST & “””” & “));”

    Next Item
    Me.lstASSIGNED.Requery
    Else
    MsgBox “You didn’t select anything”, vbInformation
    Exit Sub
    End If
    DoCmd.SetWarnings True

    I have even tried adding this to the end of the code with no results
    Dim vntItem As Variant
    For Each vntItem In Me.lstASSIGNED.ItemsSelected
    Me!lstASSIGNED.Selected(vntItem) = False
    Next
    Does anyone have any ideas? dizzy

    Viewing 1 reply thread
    Author
    Replies
    • #650969

      Off the cuff, changed the Multiple Selection property to Extended. When it is simple, the ‘selected’ items are maintained when you requery, but when it’s extended, they disappear when requerried. Just an FYI, in Simple mode, you click each item you want. In Extended, clicking one item, and then another will select only the last item. You have to hold the Ctrl button down to select multiples, or the shift key to select from one point to another.

      • #650973

        Drew,
        As stated above, the listbox is already set that way.
        Thanks anyway

        • #650974

          Ack, my bad, why I missed that part, I don’t know. Would you mind sending me a copy, so I can take a look?

          • #650975

            Drew,
            I can’t do it today. Since its part of a large db, I’ll have to slice that part off and put some dummy data into it.
            I’ll see if I can do that tomorrow.
            Thanks

    • #651238

      Did you put the code to deselect the items before the Requery of the list box? If you requery it before deselecting, the display is already messed up (in a test I did, empty rows below the end of the list displayed as selected), and Requery doesn’t correct it.

      • #651289

        Hans,
        I put the deselect as the last statement of the code

        • #651290

          Uhm, I guess I didn’t make myself clear – my reply was meant as a suggestion as well as a question. So to be more explicit:

          Put the code to deselect all listbox items before the statement that requeries the list box.

          • #651293

            Hans,
            That took care of the problem. After re-reading rtfm your previous post I saw what you were asking(telling) me to try.
            thankyouThanks and have a great day,
            Scott

    Viewing 1 reply thread
    Reply To: MultiSelect Listbox (A2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: