hello all
I hope you're happy
I've encountered a problem! Please help me if you can.
The problem is about ListBox Initialization! I'm using a query to select a column's values from a table and filling the ListBox with that values. It works great when records number are low but when records number reach to thousands the initialization of ListBox becomes so slow! do you have any offer for me to speed up the process of initialization? thanks so.
I hope you're happy
I've encountered a problem! Please help me if you can.
The problem is about ListBox Initialization! I'm using a query to select a column's values from a table and filling the ListBox with that values. It works great when records number are low but when records number reach to thousands the initialization of ListBox becomes so slow! do you have any offer for me to speed up the process of initialization? thanks so.
Code:
Private Sub EnableRelatedListBox(ListBoxTag As String)
Dim lngRow As Long
Dim ctl As Control
Dim check As CheckBox
Dim lst As ListBox
Dim SqlStr As String
Set check = Me.Controls(ListBoxTag)
Set lst = Me.Controls("List" & ListBoxTag)
If check.Value Then
SqlStr = "SELECT ResultedTableForMmtReport." & ListBoxTag & " FROM ResultedTableForMmtReport GROUP BY ResultedTableForMmtReport." & ListBoxTag & ";"
For Each ctl In Me.Controls 'Query every Control on the Form
If ctl.ControlType = acListBox Then 'Is it a Check Box?
ctl.Visible = False
End If
Next
lst.Visible = True
lst.Enabled = True
lst.RowSource = SqlStr
TempVars(ActiveControl.Tag & "st").Value = " (1=1) "
Me.Refresh
For lngRow = 0 To lst.ListCount - 1
lst.Selected(lngRow) = True
Next
Else
For lngRow = 0 To lst.ListCount - 1
lst.Selected(lngRow) = False
Next
lst.Visible = False
lst.Enabled = False
lst.RowSource = ""
TempVars.Remove (lst.Tag & "st")
Me.Refresh
End If
Set ctl = Nothing
Set lst = Nothing
Set check = Nothing
End Sub