Refreshing/Clearing selections in a list box

T

TBernard

I have a from with two list boxes, the users can
select "highlight" records in the first list box and click
a button to add them to the 2nd list box. Everything is
working correctly, but I cannot get the highlighted
selecter to remove from the first list box.

So if the user selects one record and clicks "Add" to add
it to the 2nd list box, then decides they want to select
one more record, they must first unselect the highlighted
record (it automatically highlights the next record down
from the previous selected record once it is removed from
the first list box).

Here is the code I have tried, but has not worked:

lstMyListBox = Null

and

lstMyListBox = Empty

Neither seem to work, if anyone has any advice or any
ideas it would be greatly appreciated.

Thank you,

TBernard
 
J

John S

I'm not exactly sure what you are trying to do, but you have to set the
selected property to false, and cycle through the list:

Dim z As Integer
For z = 0 To lst.ListCount - 1 Step 1
lst.Selected(x) = False
Next z

VB has a method to clear a list box, and to clear items selected too, I
think, but VB Access does not.

John S
Aylmer, PQ
 
J

John S

Damn thing didn't post -- trying again.

You have to use the selected property and cycle through the list box. The
code is thus:

Dim z As Integer
For z = 0 To lst.ListCount - 1 Step 1
lst.Selected(x) = False
Next z

John S.
Aylmer, PQ
 

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