Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MultiSelect Listbox (A2k)

    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? <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>

  2. #2
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect Listbox (A2k)

    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.

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect Listbox (A2k)

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

  4. #4
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect Listbox (A2k)

    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?

  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect Listbox (A2k)

    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

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: MultiSelect Listbox (A2k)

    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.

  7. #7
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect Listbox (A2k)

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

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: MultiSelect Listbox (A2k)

    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.

  9. #9
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect Listbox (A2k)

    Hans,
    That took care of the problem. After re-reading <img src=/S/rtfm.gif border=0 alt=rtfm width=24 height=23> your previous post I saw what you were asking(telling) me to try.
    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>Thanks and have a great day,
    Scott

Posting Permissions

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