title: Access 2007 VBA: how to get / change the current record's position on the screen
body: <p>I have an Access 2007 form that displays 40 rows. When I open it, I would like the current record's row to be displayed at row position #5, out of the 40 rows displayed. In other words, there should be 4 rows above the current row, and 35 rows below it. </p>
  
  <p><em>MoveUpDown</em> is my first cut at doing this, but currently it only works if the current record's row (as moved to by <em>FindFirst</em>) is initially displayed at row positions #1 through #5. How do I find what the current row's displayed position is, relative to the displayed rows, and how do I change it? Thanks.</p>
  
  <pre><code>Private Sub OpenMyFormTo(sqlWhere As String)
      Dim rs As DAO.Recordset, frm As Form
      DoCmd.Openform "myForm", acNormal
      Set frm = Forms("myForm").Form
      Set rs = frm.RecordsetClone
      If Not (rs.BOF And rs.EOF) Then
          rs.MoveFirst
          rs.FindFirst sqlWhere
          frm.Bookmark = rs.Bookmark
          MoveUpDown frm.Recordset, 5
      End If
  End Sub
  
  Private Sub MoveUpDown(rs As DAO.Recordset, RowsToMove As Integer)
      Dim RowsActuallyMoved As Integer, i As Integer
      RowsActuallyMoved = 0
      For i = 1 To RowsToMove
          If Not rs.BOF Then
              rs.MovePrevious
              RowsActuallyMoved = RowsActuallyMoved + 1
          End If
      Next i
      For i = 1 To RowsActuallyMoved
          If Not rs.EOF Then rs.MoveNext
      Next i
  End Sub
  </code></pre>