How to Select All in List Box

D

DOYLE60

I have a combo box on a form. After update, I would like a list box to show
all selected, all blackened. What is the code for such an action?

Also, what is the opposite code? What is the code for deselecting the chosen
items in a list box, making it appear all white?

Boy! Combo boxes are easier!

Thanks,

Matt
 
T

Tim Ferguson

(e-mail address removed) (DOYLE60) wrote in
I have a combo box on a form. After update, I would like a list box
to show all selected, all blackened. What is the code for such an
action?

Assuming that you have set it to a multiselect, you just manipulate the
Selected() array:

for i = 0 to cboMyCombo.ListCount -1
cboMyCombo.Selected(i) = True
next i
Also, what is the opposite code? What is the code for deselecting the
chosen items in a list box, making it appear all white?

Set them to false.

HTH


Tim F
 
D

DOYLE60

Thanks Tim,
It is not working. It says "Variable not defined" for that "i" below.
Yes, it's a multi-select.

I wish to place this code in the "After Update" of a combo box and in the on
open of the form and perhaps on the single click of a command button. Thanks
again,

Matt

__________________________
 
D

DOYLE60

Also, in the code below, is the "cboMyCombo" part supposed to be the List Box?
I assumed so.

Matt
____________________________

for i = 0 to cboMyCombo.ListCount -1
cboMyCombo.Selected(i) = True
next i
 
T

Tim Ferguson

(e-mail address removed) (DOYLE60) wrote in m07.aol.com:
It is not working. It says "Variable not defined" for that "i" below.

I left all the stuff like the Dim statements for you... :) Anything round
here that does not have extensive disclaimers on it is almost always
pseudocode!!

And yes, your original post talked about a combo box, but of course the
multiselect stuff only applies to real lists!

HTH


Tim F
 

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