G
Guest
Hi everybody. I'm filling a listbox with a recordset, but when the amount of
items is a little bit big (around 1300), the listbox seems to be disable, I
can only see the borders. I tried to divide the items into two listboxes, the
first 1000 items in the first list box and the rest in the second one, but
now, it disables the second one, even only with less than 500 items to be
fill in this second listbox.
Here is the code.
Set rst = dbs.OpenRecordset(str_query, dbOpenDynaset)
If Not rst.EOF Then rst.MoveFirst ' Go to the first item
Lst_item.RowSource = "" ' Delete old elements in
listbox
' while there are elements in the query
Do While Not rst.EOF
Lst_item.AddItem rst.Fields(0).Value ' Add the element to the
listbox
rst.MoveNext
k = k + 1
If k = 1000 Then ' If the number of elements goes over 1000
GoTo L_Over_Max
End If
Loop
L_Next:
' Close query
rst.Close
StatusBar ("Ready")
Exit Sub
' If the number of elements if over 1000 it works with the second listbox
L_Over_Max:
Lst_item2.RowSource = "" ' Clear old elements
Do While Not rst.EOF
Lst_item2.AddItem rst.Fields(0).Value
rst.MoveNext
Loop
GoTo L_Next
Where is the problem? I'm working with access 2003.
Thanks
items is a little bit big (around 1300), the listbox seems to be disable, I
can only see the borders. I tried to divide the items into two listboxes, the
first 1000 items in the first list box and the rest in the second one, but
now, it disables the second one, even only with less than 500 items to be
fill in this second listbox.
Here is the code.
Set rst = dbs.OpenRecordset(str_query, dbOpenDynaset)
If Not rst.EOF Then rst.MoveFirst ' Go to the first item
Lst_item.RowSource = "" ' Delete old elements in
listbox
' while there are elements in the query
Do While Not rst.EOF
Lst_item.AddItem rst.Fields(0).Value ' Add the element to the
listbox
rst.MoveNext
k = k + 1
If k = 1000 Then ' If the number of elements goes over 1000
GoTo L_Over_Max
End If
Loop
L_Next:
' Close query
rst.Close
StatusBar ("Ready")
Exit Sub
' If the number of elements if over 1000 it works with the second listbox
L_Over_Max:
Lst_item2.RowSource = "" ' Clear old elements
Do While Not rst.EOF
Lst_item2.AddItem rst.Fields(0).Value
rst.MoveNext
Loop
GoTo L_Next
Where is the problem? I'm working with access 2003.
Thanks