select first item in listbox onLoad/Open

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?!
 
K

Ken Snell [MVP]

Assuming that the listbox is not a multiselect listbox:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top