ItemsSelected in MultiSelect Listbox

P

PeterM

I'm using AC2003. I have a multiselect listbox set to simple (List4). I
need to loop thru all selected items. The listbox has 2 columns in it.
Here's the code I have:
Dim tmpCTR as Long
Dim varItm As Variant
For Each varItm In Me.List4.ItemsSelected
tmpCTR = tmpCTR + 1
Next varItm

MsgBox tmpCTR

When I run it in debug, once it hits the For Each code, it goes directly to
the msgbox command and then displays 0 even when I have 4 items selected.
It's not even looping thru once.

I've looked thru this forum and found many examples pertaining to what I
need. As far as I can tell, my code should work. Does anyone have any idea
why it is not?

Thanks in advance for you time!
 
W

Wayne-I-M

Can you explain what you are trying to do.

I think you're trying to increase a value in a control by 1 (tmpCTR = tmpCTR
+ 1) for each record selected in a list box. Is this right ?.
Can you give more detales about control names, etc and then someone will be
able to offer some help
 
J

Jon Lewis

I can't reproduce the problem. This works fine for me.

Incidently, you may have been just trying to illustrate the problem but you
are aware that the ItemsSelected has a Count property if this is really what
you wanted?

Jon
 
P

PeterM

Never mind, thank you both for responding. I'm a complete idiot. I was
checking the wrong listbox on the form. Once I made the change it worked
fine. Again, accept my apologies for my stupidity.

Pete
 

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