Select 1st Item

  • Thread starter Thread starter CJ
  • Start date Start date
C

CJ

Hi again Groupies

When the listbox on my form receives the focus, I would like it's first
record to be selected. How do I make this happen with code?

I have tried:

Private Sub lstShopInventory_GotFocus()
Dim rst As DAO.Recordset
Me.Refresh
Set rst = Me.Recordset
rst.GetRows 1
End Sub

....nothing happened....
 
CJ said:
Never mind, I got it.

Me.Refresh
SendKeys "^{HOME}"

Ugh! PLEASE don't go with that. Sendkeys is notoriously unreliable. Also it
will be quietly ignored under Vista.

The correct way to select the 1st item is:

Me.MyListbox.Value = Me.MyListbox.ItemData(0)
 
I changed it, thanks for the tip.........however, it was working on my Vista
machine with A2K7
 
Back
Top