Marking items as selected in a Muli-Select listbox

M

Mark A. Sam

Hello,

I have a Multi-Select listbox in which I want to mark items selected
according to a field value.

If lstSelectClient.Column(4) <> 0

Then I want the item highlighted as selected, else not selected.

Background: [lstSelectClient] is a client list which connects employees to
clients. An employee listbox is beside it on the form. [lstSelectClient]
can be filtered by the selected employee or all client records will display
depending on a toggle button. If the user clicks on the [lstSelectClient]
list it toggles the value of Column(4) from 0 to the empolyee number. When
all of the client records are showing is when I when I want the records
highlighted. I hope that makes sense.


Thanks for any help and God Bless,

Mark A. Sam
 
D

Douglas J. Steele

Untested, but try:

For lngLoop = 0 To (Me!MyListbox.ListCount - 1)
Me!MyListbox.Selected(lngLoop) = (Me!MyListbox.Column(4, lngLoop) <> 0)
Next lngLoop
 
M

Mark A. Sam

Thanks Doug,

I had pretty much the same method as you gave me. I was trying to implement
it from the AfterUpdate event of the listbox. When I moved it to the click
event it worked. Your method was less lines than mine so I used it.

God Bless,

Mark


Douglas J. Steele said:
Untested, but try:

For lngLoop = 0 To (Me!MyListbox.ListCount - 1)
Me!MyListbox.Selected(lngLoop) = (Me!MyListbox.Column(4, lngLoop) <>
0)
Next lngLoop

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Mark A. Sam said:
Hello,

I have a Multi-Select listbox in which I want to mark items selected
according to a field value.

If lstSelectClient.Column(4) <> 0

Then I want the item highlighted as selected, else not selected.

Background: [lstSelectClient] is a client list which connects employees
to clients. An employee listbox is beside it on the form.
[lstSelectClient] can be filtered by the selected employee or all client
records will display depending on a toggle button. If the user clicks on
the [lstSelectClient] list it toggles the value of Column(4) from 0 to
the empolyee number. When all of the client records are showing is when
I when I want the records highlighted. I hope that makes sense.


Thanks for any help and God Bless,

Mark A. Sam
 

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