Clearing a list selection and value stored against it

Mr Clevver

Idiot Savant
Local time
Today, 18:10
Joined
Jun 26, 2008
Messages
17
Hi all (again),

I have another small issue that, hopefully, should be as simple to resolve as the last one.
I have a form which contains a list box (list20), and two buttons. The first button (add/edit), when clicked, opens a form which either displays the data for the item selected in the list or if no item is selected opens the form blank, to enter a new record. The second button (clear selection) clears the list selection using the code:

Code:
 Dim i As Integer

    For i = 0 To List20.ListCount - 1
    Me.List20.Selected(i) = False
    Next i
My problem is that clearing the list in the way does not seem to clear the value Access has stored against this list selection behind the scenes. Meaning that if I select the first item in the list, click the clear button, then click add/edit - instead of getting the form to enter a new record I instead get the form displaying the first record (despite it now not being selected).

Is there possibly a line of code I can use to clear this saved value?

I hope that's clear.
 
Is this a multi-select list box? ... If NOT, then the Selected property is NOT the correct choice. All the Selected() property does is turn on/off the black hilite, but it does nothing to set or clear the value a single select list box returns.

If this is a single select list box, which I presume it is, you will just need to set the list box to Null, then your hilite will clear AND your list box value will be reset ...

Me.List20 = Null
 
Ah, that simple eh?
Now don't I feel the goober.

Thanks.
 

Users who are viewing this thread

Back
Top Bottom