On opening a form, highlight the first record in a list box...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My form displays all records in a list box (unbound), and then by selecting
any record the user can display some record details in the form's text
boxes(the form is bound to a query). The list box after update event is set
up by a wizard:

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Entry ID] = " & Str(Nz(Me![EntriesList], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

This works great, but when the user opens the form, no record is
highlighted, and the details in the text boxes belong to some record down in
the list. This is confusing to the user.

I would like to open the form and have the first record in the list
highlighted, and have the details in the text boxes belong to the first
record which is highlighted. This is what the user would expect if he
clicked on the frst record.

thanks very much for any assistance. (access 2003)
 
BetoWing said:
My form displays all records in a list box (unbound), and then by selecting
any record the user can display some record details in the form's text
boxes(the form is bound to a query). The list box after update event is set
up by a wizard:

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Entry ID] = " & Str(Nz(Me![EntriesList], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

This works great, but when the user opens the form, no record is
highlighted, and the details in the text boxes belong to some record down in
the list. This is confusing to the user.

I would like to open the form and have the first record in the list
highlighted, and have the details in the text boxes belong to the first
record which is highlighted. This is what the user would expect if he
clicked on the frst record.

(access 2003)


I think you can get that effect by using this in the form's
Load event:

Me.EntriesList = Me.EntriesList.ItemData(0)
Me.EntriesList_AfterUpdate

Or maybe this:

Me.EntriesList.SetFocus
Me.EntriesList.ListIndex = 0
 
--
BobWingmeister


Marshall Barton said:
BetoWing said:
My form displays all records in a list box (unbound), and then by selecting
any record the user can display some record details in the form's text
boxes(the form is bound to a query). The list box after update event is set
up by a wizard:

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Entry ID] = " & Str(Nz(Me![EntriesList], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

This works great, but when the user opens the form, no record is
highlighted, and the details in the text boxes belong to some record down in
the list. This is confusing to the user.

I would like to open the form and have the first record in the list
highlighted, and have the details in the text boxes belong to the first
record which is highlighted. This is what the user would expect if he
clicked on the frst record.

(access 2003)


I think you can get that effect by using this in the form's
Load event:

Me.EntriesList = Me.EntriesList.ItemData(0)
Me.EntriesList_AfterUpdate

Or maybe this:

Me.EntriesList.SetFocus
Me.EntriesList.ListIndex = 0
The last two line worked like a charm. Thanks for your help.
 
Back
Top