I just want to select an item in a listbox!!

Benjamin Bolduc

Registered User.
Local time
Today, 12:55
Joined
Jan 4, 2002
Messages
169
Hi Everyone!

I'm having problems and am frustrated as usual ;)

I'm trying to select a specific row in a listbox in the OnKeyDown event on my form. Basically, while in a subform, I want the enter key to move the focus to the list box, specifically to row After the last selected.

Here's an example of the code I thought would work:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ItemNumber As Integer

ItemNumber = Forms![Product Inventory System]![InvList3] + 1

If KeyCode = vbKeyReturn Then
Forms![Product Inventory System]![InvList3].ItemData(ItemNumber).SetFocus

Else

End If
End Sub

I just started the Atkins diet today, so my sugar and caffiene levels are non-existant. (Seems like an easy excuse, right?)

Can anyone offer any insight into what I'm doing wrong?

Thank you so much!
Ben Bolduc
 
Check out the ListIndex and Selected properties of a listbox
Code:
Me.List1.Selected(Me.List1.ListIndex + 1) = True
 
Wooohoo! Thanks :)

Using this, I fixed my problem and also enhanced some of the other feature of the form.

Thank again,
Ben
 

Users who are viewing this thread

Back
Top Bottom