Turn off listbox selection?

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.
 
G

George Nicholson

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
 
M

mscertified

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
 

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