have taken over on a project making enhancements to an auditing tool. It has one module that takes in stock entries and loads values into a list box to "remember" the last selected list.
The code being used to popluate this list box on form load is below, but it takes an absolute age (maybe 60 secs - which is deemed unacceptable) to run through this procedure if there are more than 2000 records or so.
What i am wondering if whehter there is any other way to update this list box object other than looping through each value and updating as below.
Any suggestions would be much appreciated.
Andrew
Dim iCurrentRow As Integer
Dim ssql As String
Dim totalRows As Long
'* Iterate through the multi-list object and either selecting or deselecting all choices
totalRows = Me.lstType.ListCount
With Me.lstType
'For iCurrentRow = 0 To .ListCount - 1
For iCurrentRow = 0 To Me.lstType.ListCount - 1
Select Case bySelectAll
Case 1 '* True
.SELECTED(iCurrentRow) = True
Case 2 '* Invert
.SELECTED(iCurrentRow) = Not (.SELECTED(iCurrentRow))
' Case 3 '* Invert
' .Selected(iCurrentRow) = DLookup("Selected", "tblTYPE", "type like '" & LTrim(Me.lstType.Column(0, iCurrentRow)) & "'")
End Select
Next iCurrentRow
End With
The code being used to popluate this list box on form load is below, but it takes an absolute age (maybe 60 secs - which is deemed unacceptable) to run through this procedure if there are more than 2000 records or so.
What i am wondering if whehter there is any other way to update this list box object other than looping through each value and updating as below.
Any suggestions would be much appreciated.
Andrew
Dim iCurrentRow As Integer
Dim ssql As String
Dim totalRows As Long
'* Iterate through the multi-list object and either selecting or deselecting all choices
totalRows = Me.lstType.ListCount
With Me.lstType
'For iCurrentRow = 0 To .ListCount - 1
For iCurrentRow = 0 To Me.lstType.ListCount - 1
Select Case bySelectAll
Case 1 '* True
.SELECTED(iCurrentRow) = True
Case 2 '* Invert
.SELECTED(iCurrentRow) = Not (.SELECTED(iCurrentRow))
' Case 3 '* Invert
' .Selected(iCurrentRow) = DLookup("Selected", "tblTYPE", "type like '" & LTrim(Me.lstType.Column(0, iCurrentRow)) & "'")
End Select
Next iCurrentRow
End With