michael1174
asked on
Select and deselect multi select listbox in Access
Experts,
Right now, I am running the following code to either select or deselect all rows in the mult select listbox. Sometimes the listbox contains many values and there is a several second delay when running this code. I was wondering if there was a quicker way to select or deselect all rows in the listbox?
Thanks!
Right now, I am running the following code to either select or deselect all rows in the mult select listbox. Sometimes the listbox contains many values and there is a several second delay when running this code. I was wondering if there was a quicker way to select or deselect all rows in the listbox?
Thanks!
For index = 1 To Me.lstStringID.ListCount
Me.lstStringID.Selected(index - 1) = False
Next index
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That's funny. Believe it or not, I have never thought of that until RIGHT NOW! And I've got many places where I use MSLB's with Select All and Select None buttons. Looks I will be modifying some code.
Again, how many list items worst case here ?
mx
Again, how many list items worst case here ?
mx
ASKER
hey, just like they say, you learn something new everyday!
anyway, i have these counts and i am listing the "products" in the listbox:
ProductID CountOfProductID
1 800
2 101
3 1463
4 441
5 3932
6 2135
anyway, i have these counts and i am listing the "products" in the listbox:
ProductID CountOfProductID
1 800
2 101
3 1463
4 441
5 3932
6 2135
Sorry, I'm not clear on the number of list box items (max) at one time?
Also ... I've tried various ways to speed up Select All, but haven't had much success. It's pretty much a limitation of the list box control.
mx
Also ... I've tried various ways to speed up Select All, but haven't had much success. It's pretty much a limitation of the list box control.
mx
This might work also:
Me.YourListBoxName.RowSour ce = Me.YourListBoxName.RowSour ce
Me.YourListBoxName.RowSour
to select all items in listbox
With Me.List0
For j = 0 To .ListCount - 1
.Selected(j) = True
Next
End With
to deselect all
With Me.List0
For j = 0 To .ListCount - 1
.Selected(j) = false
Next
End With
With Me.List0
For j = 0 To .ListCount - 1
.Selected(j) = True
Next
End With
to deselect all
With Me.List0
For j = 0 To .ListCount - 1
.Selected(j) = false
Next
End With
MX,
I guess the limit is about 65000, beyond that one needs to use a UserDefineFunction.
I guess the limit is about 65000, beyond that one needs to use a UserDefineFunction.
eghtebas - I am asking him how many he has ... that the max possible.
mx
mx
mx,
Thanks. But it could be read both ways.
Thanks. But it could be read both ways.
I meant "NOT the max possible" ... typo
mx
mx
ASKER
I have a combo box controlling the listbox, so I was giving the max per product. So, the max would be 3932 rows.
That's a LOT of rows. Not sure you are going to be able to significantly improve the Select All with that many rows!
I personally fell that is way beyond the original intent of a list/combo box.
mx
I personally fell that is way beyond the original intent of a list/combo box.
mx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
JEFF .... long time no see !!! Happy Ho to you. Hope you get out this way some day.
joe
joe
ASKER
To select All, in my listbox I added a row called "All" for the first row in my listbox. I put in "All" by adding a union to the underlying row source query such as:
select "*" AS ID, "(All)" AS description
from tblProduct
union
select ProductID, Product
from tblProduct
OrderBy Description
Thanks..
select "*" AS ID, "(All)" AS description
from tblProduct
union
select ProductID, Product
from tblProduct
OrderBy Description
Thanks..
ASKER