Can't deselect item in non-multi-select listbox? (1 Viewer)

AOB

Registered User.
Local time
Today, 01:21
Joined
Sep 26, 2012
Messages
615
Then you never had a single column to begin with. Have we moved on to a new problem since this is not the solution to the problem you came here with?

Sorry, yes... I guess so, yes.

My original problem was providing an intuitive method to allow users to deselect an item in a listbox. As I explored options, I discovered that a continuous subform, as an alternative to the listbox, would solve a different set of problems that arose (nothing to do with item selection).

But it so transpired that it also solved this problem because I could control / manipulate the selection behaviour in the subform, more easily than with the listbox. So, yes, you are correct, apologies for the crossed wires there! :oops:
 

ebs17

Well-known member
Local time
Today, 02:21
Joined
Feb 7, 2020
Messages
1,946
My original problem was providing an intuitive method to allow users to deselect an item in a listbox
It would have been a neat way to check for a pressed special key (Ctrl, Alt, Shift) on the click event and then assign zero to the list field.
 

AOB

Registered User.
Local time
Today, 01:21
Joined
Sep 26, 2012
Messages
615
It would have been a neat way to check for a pressed special key (Ctrl, Alt, Shift) on the click event and then assign zero to the list field.

Yes, see post #5 in this thread (pretty much what you're describing)
 

ebs17

Well-known member
Local time
Today, 02:21
Joined
Feb 7, 2020
Messages
1,946
Code:
Private Declare Function GetKeyState% Lib "user32" (ByVal vkey As Long)

Private Sub MyListBox_Click()
   If Abs(GetKeyState(17) < 0) Then                  ' CTRL+
      Me.MyListBox = NULL
   End If
End Sub
 
Local time
Yesterday, 20:21
Joined
Sep 16, 2023
Messages
35
There is one more option that I think is not exposed and that is to place it as the first row (Select a row) and this first row deselects all the others but will not be taken into account.
Or also say "unselect here"
Nothing out of this world but it is an option
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 20:21
Joined
Feb 19, 2002
Messages
43,293
Why would that be normal behaviour by design I wonder?
To make it work more like a textbox. There is no "undo" for the text box either but exc will clear the last entered value. Esc, esc will clear all updates to the form that have not been committed.
 

Users who are viewing this thread

Top Bottom