remember what last record was

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
 
M

Marshall Barton

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.
 

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