Listbox .Selected=False won't work

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

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

Douglas J. Steele

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

Branislav Mihaljev

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
 
D

Douglas J. Steele

Don't think that works with multiselect lists, or if it does, it only works
with one type of multselect list
 
D

David W. Fenton

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.
 

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