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?