Listbox "before update"-event (1 Viewer)

ino_mart

Registered User.
Local time
Today, 15:04
Joined
Oct 7, 2009
Messages
78
All

I have a listbox where all of the values are selected by default on opening the form.

The user is able to (de)select values, but there must always be at least 1 value selected.

What is the target?
Suppose there is currently one item selected. If the user deselects it, that specific entry must be automatically reselected.

I tried to to this in a "before update"-event of the listbox, but this does not work. The item gets deselected and the "cancel=true" does not do the reselect.

Code:
Private Sub lstFilterDate_BeforeUpdate(Cancel As Integer)
If Me.lstFilterDate.ItemsSelected.Count = 0 Then
    Cancel = True
End If
End Sub
 

Minty

AWF VIP
Local time
Today, 23:04
Joined
Jul 26, 2013
Messages
10,382
I would add a debug.print Me.lstFilterDate.ItemsSelected.Count into your code. I suspect that the count property isn't updated until after the control is updated.
 

missinglinq

AWF VIP
Local time
Today, 18:04
Joined
Jun 20, 2003
Messages
6,420
...The user is able to (de)select values...

You can only deselect a Value in a Listbox, using the Listbox itself, if the MultiSelect Property is set to Simple...is that the case, here?

If not, how, exactly, can your users 'deselect' a Value?

Linq ;0)>
 

Users who are viewing this thread

Top Bottom