[AccessD] Slow loop through list box

Gustav Brock gustav at cactus.dk
Wed Sep 24 03:24:39 CDT 2003


Hi David

It sounds/looks like you are building the complete list every time an
item is selected. Why not add only that item which has been selected?

/gustav


> 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.



More information about the AccessD mailing list