[AccessD] Slow loop through list box

Gustav Brock gustav at cactus.dk
Fri Sep 26 04:47:40 CDT 2003


Hi David

Thanks ... if you experience any improvements when benchmarking
please let us know.

/gustav


> Thanks.  I much appreciate the help from all on this one.

> David

> At 25/09/2003, you wrote:
>>Hi David
>>
>>Well, how about the Click event ...?
>>This will also fire when using keys.
>>
>><code>
>>
>>   Dim lst         As ListBox
>>
>>   Dim lngIndex    As Long
>>   Dim strKey      As String
>>   Dim booSelected As Boolean
>>
>>   Set lst = Me!lstDemo
>>   With lst
>>     lngIndex = .ListIndex + Abs(.ColumnHeads)
>>     strKey = .ItemData(lngIndex)
>>     booSelected = .Selected(lngIndex)
>>   End With
>>
>>   MsgBox strKey & ":" & Str(booSelected)
>>
>>   If booSelected = True Then
>>     ' Append strKey to collection/selection.
>>   Else
>>     ' Remove strKey from collection/selection.
>>   End If
>>
>>   Set lst = Nothing
>>
>></code>
>>
>>However, the event will fire also when using the navigation keys.
>>Thus, I would follow the advice of Drew to append/remove the selected
>>items to an (interim) collection or array and only run the
>>append/delete action query (or code) on the table if an item really is
>>appended or removed from the collection or array.
>>
>>/gustav
>>
>>
>> > How do I determine which item has just been selected/deselected?  Then I
>> > could add it if selected, or delete if deselected.
>>
>>
>> >>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?



More information about the AccessD mailing list