I believe that I have an answer, although for me this seems awkward. This procedure finds the target line, scrolls down until the target line is visible, scrolls back to the target line, exceeds the job with additional lines (offset), and then scrolls back to the target line. The result is that the target line is displayed as the (Offset + 1) th visible line. If the number of lines is <Offset, then it is displayed as the last line.
Private Sub DisplayWithOffset(frm As Form, sqlWhere as String, Offset As Integer) Dim rs As DAO.Recordset, DetailsHt As Long, RowHt As Long, i As Integer Dim RowsVisible As Integer, BookmarkAP As Integer, RowsMoved As Integer DetailsHt = frm.InsideHeight _ - frm.Section(acHeader).Height - frm.Section(acFooter).Height RowHt = frm.Section(acDetail).Height RowsVisible = IIf(RowHt > 0, DetailsHt Mod RowHt, 0) Set rs = frm.Recordset If Not (rs.BOF And rs.EOF) Then rs.MoveLast rs.FindFirst sqlWhere BookmarkAP = rs.AbsolutePosition RowsMoved = 0 For i = 1 To RowsVisible If rs.AbsolutePosition + 1 < rs.RecordCount Then rs.MoveNext RowsMoved = RowsMoved + 1 End If Next i Do Until rs.AbsolutePosition = BookmarkAP rs.MovePrevious Loop RowsMoved = 0 For i = 1 To Offset If rs.AbsolutePosition > 0 Then rs.MovePrevious RowsMoved = RowsMoved + 1 End If Next i For i = 1 To RowsMoved rs.MoveNext Next i End If End Sub
source share