Listbox how to select row without editable cell

I have a 5 column listbox (LB1) populated with data from a sqlite database. When the user clicks on a row, further information is displayed in another listbox (LB2), using relational links to a second database.

This all works ok, but there is one thing I want to change. When the user clicks on a row in LB1, the additional data is loaded into LB2, but the cell clicked on in LB1 becomes editable, and has a blue border and pale blue background.

I have stopped the whole row in LB1 being highlighted by using me.ListIndex = -1 in the Change event of LB1, but this doesn’t stop the blue border etc on the clicked cell.

Can someone please help! I’ve searched for hours looking for the answer but without success!!

Also, a very strange thing happens when, having clicked on a row in LB1, I click on a different row in LB1. Before I release the mouse (i.e MouseDown) the additional data for the first row in LB1 appears in LB2, and then when I release the mouse (MouseUp) the data in LB2 changes to the correct data for the row selected in LB1. It’s always the info derived from whatever is in the first row of LB1 that appears initially in LB2, even if I have sorted LB1 on a different column - different info then appears in LB2 on MouseDown, to be replaced by the correct data in LB2 on MouseUp.

I have no Mouse up or down or anything else in the code!

Thanks for your help, and Happy New Year!

You mean that:

You should be populating the second listbox from the Change event, not from mouse events.

Thanks Emile - yes, that’s exactly what I see and want to stop happening!

Thanks Tim - as mentioned, I have no mouse events anywhere in my code, and LB2 is populated by a Change event in LB1, as you say it should be.

Why is the mouse down and mouse up having an effect when there is no mouse event code?

Whether a cell is editable or not is not a mouse event ‘thing’

Search your code for CellType and isEditable and .editcell

Clicking on a row selects the row, it doesnt highlight a cell and make it into a text field.
Unless you make the cell editable yourself.

What you see is your Cell text is selected and the Edited Cell have the focus.
These are standard computer usage (User Interface feedback).

To remove the Cell Focus, you can find the answer in this forum. But here you are:

Sub CellGotFocus(row as Integer, column as Integer)
  // Remove the Cell Focus Ring in Edit Mode
  Me.ActiveCell.UseFocusRing = False
End Sub

In other words:
a. Add a new Event to your ListBox: CellGotFocus

b. Put the code below into it:

  // Remove the Cell Focus Ring in Edit Mode
  Me.ActiveCell.UseFocusRing = False

And for the text selection, it is more complex; you have to use your own TextField instead of the one embedded in the ListBox and who is used at Cell Edit Time (.SelStart and .SelLength are not implemented there).

Many thanks Emile - much appreciated. I’ll investigate!

Thanks Jeff - That was very helpful