Listbox .Selected=False won't work

  • Thread starter Thread starter Ronald
  • Start date Start date
R

Ronald

Hi.

In Access 2003 I have an unbound listbox with 2 columns. It's all standard,
no multiselect.
In the OnClick event of the listbox I use the 2 values in the columns and
then want to reset the selected row.
To do this I've tried:

Me![lstListbox].Selected(Me![lstListbox].ListIndex) = False

For Each varItem In Me![lstListbox].ItemsSelected
Me![lstListbox].Selected(varItem) = False
Next varItem

For lngRow = 0 To Me![lstListbox].ListCount - 1
Me![lstListbox].Selected(lngRow) = False
Next lngRow

but none of them work.
Why?
Please help.

Ronald.
 
Thank you, Douglas.

No, that doesn't work (with or without my code). The selected row does flash
off and then on (selected) again.

Ronald.

Douglas J. Steele said:
Try:

Me![lstListbox].RowSource = Me![lstListbox].RowSource

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ronald said:
Hi.

In Access 2003 I have an unbound listbox with 2 columns. It's all
standard,
no multiselect.
In the OnClick event of the listbox I use the 2 values in the columns and
then want to reset the selected row.
To do this I've tried:

Me![lstListbox].Selected(Me![lstListbox].ListIndex) = False

For Each varItem In Me![lstListbox].ItemsSelected
Me![lstListbox].Selected(varItem) = False
Next varItem

For lngRow = 0 To Me![lstListbox].ListCount - 1
Me![lstListbox].Selected(lngRow) = False
Next lngRow

but none of them work.
Why?
Please help.

Ronald.
 
Sorry, I've never seen that behaviour.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ronald said:
Thank you, Douglas.

No, that doesn't work (with or without my code). The selected row does
flash
off and then on (selected) again.

Ronald.

Douglas J. Steele said:
Try:

Me![lstListbox].RowSource = Me![lstListbox].RowSource

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ronald said:
Hi.

In Access 2003 I have an unbound listbox with 2 columns. It's all
standard,
no multiselect.
In the OnClick event of the listbox I use the 2 values in the columns
and
then want to reset the selected row.
To do this I've tried:

Me![lstListbox].Selected(Me![lstListbox].ListIndex) = False

For Each varItem In Me![lstListbox].ItemsSelected
Me![lstListbox].Selected(varItem) = False
Next varItem

For lngRow = 0 To Me![lstListbox].ListCount - 1
Me![lstListbox].Selected(lngRow) = False
Next lngRow

but none of them work.
Why?
Please help.

Ronald.
 
Ronald said:
Hi.

In Access 2003 I have an unbound listbox with 2 columns. It's all
standard,
no multiselect.
In the OnClick event of the listbox I use the 2 values in the columns and
then want to reset the selected row.
To do this I've tried:

Me![lstListbox].Selected(Me![lstListbox].ListIndex) = False

For Each varItem In Me![lstListbox].ItemsSelected
Me![lstListbox].Selected(varItem) = False
Next varItem

For lngRow = 0 To Me![lstListbox].ListCount - 1
Me![lstListbox].Selected(lngRow) = False
Next lngRow

but none of them work.
Why?
Please help.

Ronald.

Hi,

Technically this is the same, but try this:

Dim strList As String
With Me.listboxName
strList = .RowSource
.RowSource = vbNullString
.RowSource = strList
End With

Regards,
Branislav Mihaljev
Microsoft Access MVP
 
Don't think that works with multiselect lists, or if it does, it only works
with one type of multselect list
 
Try:

Me![lstListbox].RowSource = Me![lstListbox].RowSource

I thought the problem was changing the selected value? All this will
do is re-assign the RowSource, which will lose any selection.
 
Back
Top