I can think of several ways to do this.
One way involves two variables to track the primary key of the records and
the current event of the form.
Assumption: the primary key of the record is a long integer (or
autonumber)
'Declare the two variables in the Declarations section of the form module.
Dim lCurrent as Long, lPrevious as Long
Private Sub Form_Current()
If Not(Me.NewRecord) Then
lPrevious = lCurrent
lCurrent = Me.PrimaryKey
End IF
End Sub
Now as you move from record to record you will always have the primary key
of the current and previous record to use in returning to the previous
record. If lPrevious is zero then you have no previous record.
The button code would depend on what your recordset was. In many of my
databases the user is working with only ONE record at a time and the
recordset consists of only one record.
There is a small problem with the above in that a new record won't have a
value and if you delete a record you can't return to it. That implies
that you will need to control lPrevious and lCurrent in the Delete and
Insert events.
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County