[AccessD] Slow loop through list box

David Emerson davide at dalyn.co.nz
Tue Sep 23 18:41:49 CDT 2003


I have a listbox which is used to select clients for including in 
reports.  When the listbox is updated I have a separate text box that shows 
the names of the clients selected and the number selected.  At the same 
time I store the ID's of the clients in a table that is used to filter out 
the required client records. The initial list box has over 1800 names.  It 
is taking about 10 seconds to update the lists each time a client is 
selected.  If I rem out the adding of ID's to the table then the time 
reduces to about 3 seconds.  The main part of the code is -

     With Me!lstClientList
         For Each varItem In .ItemsSelected
             If .Selected(varItem) = True Then
                 strList = strList & .Column(1, varItem) & vbCrLf  ' Adds 
client name to selected list
                 intClientNo = intClientNo + 1                            ' 
Counts number of selected clients
                 rst.AddNew 
'Add client ID to table
                     rst!CustIDNo = .Column(0, varItem)
                 rst.Update
             End If
         Next varItem
     End With

Any thoughts as to how I can speed up the process?  The BE is SQL2000.


Regards

David Emerson
DALYN Software Ltd
25b Cunliffe St, Johnsonville
Wellington, New Zealand
Ph/Fax (877) 456-1205 



More information about the AccessD mailing list