Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listboxes

Status
Not open for further replies.

MBall2003

Programmer
May 30, 2003
61
0
0
US
i have a list box populated with employee names, about 20 employees. how do i get it where when the last item in the list box is selected and the user presses down they go back to the first item vice versa for when the first itme is selected and the users presses up, go to the bottom

any ideas would be appreciated thanks

mball
 
sorry i post this on accident i already got it working sorry again
 
The following code placed in the listbox's keypress event procedure will do what you want. I am assuming that when you say "press down" you mean hitting the enter key.

[green]
Private Sub List0_KeyPress(KeyAscii As Integer)

If KeyAscii = vbKeyReturn Then

Dim i As Integer
i = List0.ListCount

If List0.Selected(0) = True Then

List0.Selected(i - 1) = True

ElseIf List0.Selected(i - 1) = True Then

List0.Selected(0) = True

End If

End If

End Sub

[/green]

ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top