Select 1st Item in Listbox

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
 

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