MultiSelect List Box Programming

J

J.C.

I have a MultiSelect List Box using a Query that lists x
number of names (let's say 6). I am trying to check each
row of the recordset programatically to see if one of the
column's value (let's call it "Column X") matches a
similar field in an entirely different table (let's call
it Table T).

I've tried to cycle through the list a jillion different
ways, and nothing has worked. I am unable to even access
the first row of the recordset. I can't find how to both
identify a row and access a value from one of it's columns
(not the first nor the bound column).

I think I need to either find a method to do that directly
(say, find the value of column 6 in rowindex 0, ... or ...
access the Query's underlying table directly and then
match up a counter with the list box recordset. It's easy
to obtain a value from a list box with MultiSelect set to
0 with a .Column(Column Index) method, but I think I need
to find a way to go to the top row, check the value,
increment the row counter, and check that one, looping
until the loop condition = listbox.listcount.

Ultimately, when the value of Column X in a row in the
query's recordset matches equivalent column in Table T, I
will set that row in the list box to Selected.

I have no problem with anything but the checking of each
row in the list box's recordset for one of its columns
values, and then moving to the next row.

I hope someone can help.

jc
 
D

Dan Artuso

Hi,
If all you want to do is loop through the values in a listbox, then:

Dim i as Integer

For i = 0 To yourListBox.RowCount -1
MsgBox yourListBox.Column(2,i)
Next i

The above will list the value in the 3rd column for all rows in the listbox.
Don't forget, the Column property has an optional 'row' argument.
 
J

J.C.

Dan -

Thanks so much! I was unaware of the optional row
argument. Solved my problem!

jc
 

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