DoCmd.GotoRecord blah blah OFFSET

H

Hugh Horton

How do I determine the offset or "record number" of a
record in a form in order to return to it later using
DoCmd.GotoRecord ....goto offset?
 
A

Allen Browne

Hi Hugh

Access does not have record numbers, or work in offsets. In general, the
best idea is to save the primary key value of the record, and later
FindFirst in the form's RecordsetClone and set the Bookmark. This approach
works even if the form has been requeried, filtered, or sorted differently,
because the primary key is the only unchangeable in those scenarios.

If necessary, it is possible to work with offsets using the Move method of
the form's RecordsetClone.

More information in article:
What, no record numbers?
at:
http://allenbrowne.com/xbase-03.html
 
P

Pieter Wijnen

It is Better to use the bookmark property
ie

Dim Bm As String
sub btnSaveRecPosition_Click()
Set Bm = me.Bookmark
End Sub

Sub BtnRetRecPosition_Click()
Me.Bookmark = bm
End Sub

HTH
Pieter
 
Top