469,948 Members | 2,920 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,948 developers. It's quick & easy.

how to reset listbox & cb box to first item after clearing

I have a function courtesy of the newsgroup that clears the list box. I
would like to now set the listbox back to its initial state where you can
see the first item in the list. The same goes for a combo box I am not sure
after clearing how to get it back to show the first item.

Regards
Peter

Function ClearList(lst As ListBox) As Boolean
If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelected
lst.Selected(varItem) = False
Next
End If
End Function
Nov 13 '05 #1
2 7773
Look in Access VBA Help for ItemData. Without looking it up, I would guess
the code would read...

Me!lstX = Me!lstX.ItemData(0)

Larry Linson
Microsoft Access MVP

"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@newsg3.svr.pol.co.uk...
I have a function courtesy of the newsgroup that clears the list box. I
would like to now set the listbox back to its initial state where you can
see the first item in the list. The same goes for a combo box I am not sure after clearing how to get it back to show the first item.

Regards
Peter

Function ClearList(lst As ListBox) As Boolean
If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelected
lst.Selected(varItem) = False
Next
End If
End Function

Nov 13 '05 #2
stupid me tried this;
Me!lstX.ItemData(0)

thanks Larry

"Larry Linson" <bo*****@localhost.not> wrote in message
news:2dI4d.9925$Bg5.4815@trnddc07...
Look in Access VBA Help for ItemData. Without looking it up, I would guess
the code would read...

Me!lstX = Me!lstX.ItemData(0)

Larry Linson
Microsoft Access MVP

"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@newsg3.svr.pol.co.uk...
I have a function courtesy of the newsgroup that clears the list box. I
would like to now set the listbox back to its initial state where you can see the first item in the list. The same goes for a combo box I am not

sure
after clearing how to get it back to show the first item.

Regards
Peter

Function ClearList(lst As ListBox) As Boolean
If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelected
lst.Selected(varItem) = False
Next
End If
End Function


Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by gv | last post: by
7 posts views Thread by Dave | last post: by
3 posts views Thread by Mark Lauser | last post: by
3 posts views Thread by kaosyeti via AccessMonster.com | last post: by
3 posts views Thread by Angel Blue01 | last post: by
15 posts views Thread by Doogie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.