Going to last record saved in list box

A

Anubix

I have a form with a list box for LastName and a tabbed control with
fields related to the person selected in the list box. The list box
is working fine when you click it, the fields show the proper
information. My problem is when I save a new person.

I'm using the following code to save a newly created record.

Private Sub cmdSaveFamily_click()

'Code that saves the record goes here...

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

Set rs = Me.RecordsetClone
rs.FindNext "[FamilyID] = " & Str(Me![FamilyID])
Me.Bookmark = rs.Bookmark
List6.Requery
List6.SetFocus
End Sub

The record is being saved but the listbox shows the first record in
the table. the FamilyID is the first one. I've tried with or without
the last two lines (Requery and SetFocus). There's no change in
behavior.

I've also tried with FindFirst and FindLast, behavior is the same.

I want it so that when I save a new record, the list box goes to the
last record saved and selects it, and so that it also selects the same
record for the related fields in the tabbed control.
 
K

Ken Snell \(MVP\)

Assuming that the listbox is not set to one of the Multiselect options, just
set the Value of the listbox to the value of the desired "record".

Me.List6.Value = Me![FamilyID]
 

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