select first item in listbox onLoad/Open

  • Thread starter Thread starter Cricri
  • Start date Start date
C

Cricri

Hi, I have that mainlite(switchboard) form with a listbox showing all my
hole_id. And all my tables are in subform in different tabs. I'd like to
have my first hole in my listbox selected when the mainlite form opens so my
subform on display would not have all these blank textboxes. I am using this
mainlite form only to view data so far. We'll see later if I want to use it
to update my tables.

I tried

If Me.lstDrillHoles.ListCount > 0 Then
Me.lstDrillHoles.ListIndex = 0
End If

and different other variations of this function. In gotFocus, OnLoad,
OnOpen event of the form, neither of it worked. I tried to put it in an
event in my listbox as well but still no success.

I am using Acces 2000.

Could anyone help me please. It is driving me mental. It should be fairly
simple right?!
 
Assuming that the listbox is not a multiselect listbox:

If Me.lstDrillHoles.ListCount > 0 Then
Me.lstDrillHoles.Value = Me.lstDrillHoles.ItemData(0)
End If
 
Back
Top