Datasheet Form, iterate through records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Johno34
    New Member
    • Jun 2023
    • 1

    Datasheet Form, iterate through records

    I have this click event on my form. It speaks to a Datasheet Subform
    Code:
    Private Sub Command260_Click()
     Dim r As DAO.Recordset
     Set r = Form_frmABCD.Form.RecordsetClone
     r.MoveFirst
     Do
        If Nz(r(2)) = "" Then
        Stop
        'Need to move form to this record.  Bookmark??
        Form_frmABCD.RunSelectForm (1)
        DoEvents
        End If
     r.MoveNext
     Loop Until r.EOF
    End Sub
    RunSelectForm is a routine normally called by a d-click in frmABCD. I'd like to use it with the above
    but it sees only the current row in the datasheet. r.MoveNext does not 'move' to the next row.
    I understand why, but unsure what is a good solution. I could use the recordset values and write a new routine.
    But if I could move to the next row in the Form automatically within the Do Loop nothing more would be needed.
    But what command might do this, if it is possible?
    Thanks for any help.
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Yes, bookmark is what you need. I believe what you need is
    Code:
    me.bookmark = r.bookmark
    in line 8, and then destroy temp objects and leave the routine.

    Jim

    Comment

    Working...