Select 1st Item in Listbox

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

Guest

What would the code be to ensure the first item in a listbox is selected
after a Save button is clicked, the form and the list box are requeried, and
the list box gets focus? Here's what I'm using now, and it's not going to the
first record in the list box.

'Button to save the changes to the current record
Private Sub saveChanges_Click()
On Error GoTo Err_saveChanges_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
MsgBox "Changes to This Record Have Been Saved", vbOKOnly, "Changes Saved"
Me.Form.Requery
Me.List0.Requery
Me.List0.SetFocus
Me.List0.ListIndex = 1
DoCmd.GoToRecord , , acFirst

Exit_saveChanges_Click:
Exit Sub

Err_saveChanges_Click:
MsgBox Err.description
Resume Exit_saveChanges_Click

End Sub

Many thanks in advance!

GwenH
 
Back
Top