Deselect or remove highlight from item in listbox (1 Viewer)

magster06

Registered User.
Local time
Today, 14:41
Joined
Sep 22, 2012
Messages
235
Hi All,

I am using Access 2010.

I have a form with three listbox. My issue is this, when I go from listbox to listbox the selected item in the previous listbox is still selected.

I would like it so when I go to the new listbox, then the previous listbox selection will no longer be highlighted.

I use the follow code, which works but the user has to double click on the listbox with the focus to make a selection, very frustrating.

Code:
Me.listbox.listindex = -1

I have the code in the lost focus event of the listboxes.

Is there a way to prevent the double clicking?

I hope that I am making sense with this; sorry if there is any confusion.
 

magster06

Registered User.
Local time
Today, 14:41
Joined
Sep 22, 2012
Messages
235
vbaInet,

Thank you for your response! I am not sure exactly how to use the "Selected" property.

I have tried:

Code:
Me.lst1UnitAlt.Selected(0) = False

but I still have to double click on the next listbox.

When I use:

Code:
Me.lst1UnitAlt.Rowsource = ""

Then this clears my listbox (which it should).

Am I to reload my listbox with a sql after it is cleared?

Sorry for my ignorance

I have attached an image of what the listboxes. In the image you can see that an item is selected in the first and second box. What I would like is when I click on the second or third listbox, then the selected item in the previous listbox with deselect.
 

Attachments

  • Untitled.png
    Untitled.png
    34.7 KB · Views: 322
Last edited:

vbaInet

AWF VIP
Local time
Today, 19:41
Joined
Jan 22, 2010
Messages
26,374
Double click for it to be highlighted? I think what's happening there is the first click sets the focus and the second click highlights a row. Try running the code in the Got Focus event of the listbox but this time deselect the other two listboxes.

You shouldn't need to keep clearing the Rowsource.
 

magster06

Registered User.
Local time
Today, 14:41
Joined
Sep 22, 2012
Messages
235
Double click for it to be highlighted? I think what's happening there is the first click sets the focus and the second click highlights a row.

Yes, I believe that is what is happening.
 

magster06

Registered User.
Local time
Today, 14:41
Joined
Sep 22, 2012
Messages
235
vbaInet,

Your idea worked!

I placed the following in the GotFocus event of the listbox that I would be making a selection in:

Code:
Me.listbox that I am leaving.Selected(0) = False

Thanks again vbaInet!
 

Users who are viewing this thread

Top Bottom