remember what last record was

  • Thread starter Thread starter Mark Kubicki
  • Start date Start date
M

Mark Kubicki

I want to add a cmd control that returns the user to the previous record
they viewed. So, I presume that I need to store some indicator of that
previos record (while it's still current) into a variable, and then use that
as the bookmark when returning to it...

my question is at what event would I store the variable (I would think it's
something like: "before current" (which , of course, doesn't exist -I
think...)

thanks in advance,
mark
 
Mark said:
I want to add a cmd control that returns the user to the previous record
they viewed. So, I presume that I need to store some indicator of that
previos record (while it's still current) into a variable, and then use that
as the bookmark when returning to it...

my question is at what event would I store the variable (I would think it's
something like: "before current" (which , of course, doesn't exist -I
think...)


Use the Current event to manage things.

Assuming the revords are identified by a Long integer or
AutoNumber primary key, the code could be like:

Private PrevRec As Long, CurRec As Long

Sub Form_Current(
PrevRec = CurRec
CurRec = Me.thePKfield
End Sub

Sub button_Click(
With Me.Recordset
.FindFirst "thePKfield=" & PrevRec
Me.Bookmark = .Bookmark
End With
End Sub

You may need some additional code to keep things straight if
you allow records to be deleted.
 
Back
Top