Populating a listbox all at once

R

rmiller1985

I've got a listbox that's populated with table/query data. There are a LOT
of records that go into this list box -- around 14k records at the moment --
and I believe the way the listbox is being populated is the cause of a
problem.

When I scroll down a page, the scroll bar goes halfway down the scroll bar
box. Then when I scroll down again, it goes halfway to the bottom again.
Another scroll, halfway again. By clicking and dragging the scroll bar, I
can get all the way to the bottom of the scroll bar box -- but when I
release, it immediately pops back up again.

I'm guessing that this behaviour indicates that the list is being populated
"on the fly," i.e., with each scroll, instead of being populated all at once
before the control is displayed.

Is there any way to change the behaviour so that the list is populated
before being displayed? Having to scroll incrementally (I can't think of a
better term at the moment) instead of being able to scroll from top to bottom
or anywhere in between immediately is a bit tedious with so many records.

(If you're thinking a list box probably isn't the best choice here, I agree.
But I've "inherited" the application, and modifying it substantially isn't
an option currently.)

Thanks,
Rich
 
M

Marshall Barton

rmiller1985 said:
I've got a listbox that's populated with table/query data. There are a LOT
of records that go into this list box -- around 14k records at the moment --
and I believe the way the listbox is being populated is the cause of a
problem.

When I scroll down a page, the scroll bar goes halfway down the scroll bar
box. Then when I scroll down again, it goes halfway to the bottom again.
Another scroll, halfway again. By clicking and dragging the scroll bar, I
can get all the way to the bottom of the scroll bar box -- but when I
release, it immediately pops back up again.

I'm guessing that this behaviour indicates that the list is being populated
"on the fly," i.e., with each scroll, instead of being populated all at once
before the control is displayed.

Is there any way to change the behaviour so that the list is populated
before being displayed? Having to scroll incrementally (I can't think of a
better term at the moment) instead of being able to scroll from top to bottom
or anywhere in between immediately is a bit tedious with so many records.

(If you're thinking a list box probably isn't the best choice here, I agree.
But I've "inherited" the application, and modifying it substantially isn't
an option currently.)


It might make the delay happen all at once, but you can use
an event (form Load?) to reference the list box's ListCount
property. This will force the list to be fully populated.

dummy = Me.listbox.ListCount
 
R

rmiller1985

Marshall Barton said:
It might make the delay happen all at once, but you can use
an event (form Load?) to reference the list box's ListCount
property. This will force the list to be fully populated.

dummy = Me.listbox.ListCount

This yielded an interesting result. When I first dragged the scroll bar
down, only a certain number of list items were displayed (I didn't count, but
it looked like maybe 100 or so). But when I released the scroll bar, it
sprang back up almost all the way to the top, and when I dragged it again,
all list items were available.

This will probably work as a workaround. I'm not sure if it'll be
sufficient for the client.

Thanks,
Rich
 
J

John Spencer

I've found that with larger numbers of items in a listbox, I need to do
something like this to force the listbox to fully populate

'Select last item in list
Me.lstShowRegistryRecords =
Me.lstShowRegistryRecords.ItemData(Me.lstShowRegistryRecords.ListCount - 1)
'Select first or second item - depends on whether you are showing column
titles to scroll back to top of list
Me.lstShowRegistryRecords = Me.lstShowRegistryRecords.ItemData(1)
'Clear the selection
Me.lstShowRegistryRecords = Null

I've not tested this on multi-select lists, but I believe it would fail to
fully populate the list (your currently observed behavior).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top