Turn off listbox selection?

  • Thread starter Thread starter mscertified
  • Start date Start date
M

mscertified

I have a listbox that allows just one row to be selected. When a row is
unselected, I'd like the click to select the row. However, when a row is
selected, I'd like a click to turn off the selection. How do I do the latter?

Thanks.
 
Here's one approach, I'm sure there are others

Private Sub lboList_Click()
Static vOldValue As Variant
'This will work for a bound or unbound Listbox.
' Note: a bound Listbox could probably use the OldValue property instead
of a static variable.

If Me.lboList = vOldValue Then
Me.lboList = Null
End If
vOldValue = Me.lboList
End Sub
 
I had to code the following to make it work:

If NZ(Me!lstDT,"") = NZ(Me!lstDT.OldValue,"") Then
Me!lstDT = Null
End If

-Dorian
 
Back
Top