moving record pointer in form

T

TracyG

I am doing a record add through form code. After the new record is added I
want to move the current record pointer to this newly added record. How do
I accomplish this?
 
A

Allen Browne

The simplest thing would be to AddNew to the RecordsetClone of the form.
Then set the form's Bookmark to LastModifed.

This kind of thing:
Dim rs As DAO.Recordset
If Me.Dirty Then 'Save first
Me.Dirty = False
End If
Set rs = Me.RecordsetClone
rs.AddNew
!SomeField = 99
!AnotherField = "xxx"
'etc
rs.Update
Me.Bookmark = rs.LastModified


If you cannot use that approach, you will need to Requery the form and then
FindFirst the new key value.
 
Top