List Hangs when selecting all Items in list (See Code)

  • Thread starter Thread starter Roger Collette
  • Start date Start date
R

Roger Collette

Hello;

I have a list box ; I use the below code to select all, or clear all similar
code . It works fine so far, but when I have a list returning 13000 records.
It hangs. Any ideas. Thanks in advance.

Roger
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub cmdSelectIssue_Click()
On Error GoTo Err_cmdSelectIssue_Click

Dim iInstr As Integer

'This is the "Select All" command button
'It scrolls through every item in the list and sets selected to true or
Highlights all records in List


For iInstr = 0 To lstInstrIssue.ListCount - 1

lstInstrIssue.Selected(iInstr) = True ' If Iset this to False it
de-select the items.

Next iInstr ************** when I debug, it is stuck here at this line


Exit_cmdSelectIssue_Click:
Exit Sub
Err_cmdSelectIssue_Click:
MsgBox Err.Description
Resume Exit_cmdSelectIssue_Click

End Sub

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
The answer seems painfully obvious. Limit the list BEFORE populating
the listbox. Pop up a modal form and prompt the user for criteria,
and then populate based on that. Or do a recordcount on the number of
records found and loop until it's a more reasonable number. I would
never ask someone to scroll through 13000 records! That's just not
usable!
 
Back
Top