views:

20

answers:

1

I have a Tabular type Form based upon a SELECT * FROM table type of query in MS access.

I would like to:

  • check / select rows in this form
  • iterate through the checked / selected rows
+1  A: 

You can use the recordset or the recordsetclone.

 With Me.Recordsetclone
    .MoveFirst
    Do While Not .EOF
        MsgBox "Field 1 is: " & .Fields(1)
        .MoveNext
    Loop
End with

You can also allow the user to highlight records and work with those (http://support.microsoft.com/kb/208502).

  Function DisplaySelectedCompanyNames()
     Dim i As Long
     Dim frm As Form
     Dim rs As DAO.Recordset

     '' Get the form and its recordset.
     Set frm = Forms![Customers]
     Set rs = frm.RecordsetClone

     '' Move to the first record in the recordset.
     rs.MoveFirst

     '' Move to the first selected record.
     rs.Move frm.SelTop - 1

     '' Enumerate the list of selected records presenting
     '' the CompanyName field in a message box.
     For i = 1 To frm.SelHeight
       MsgBox rs![CompanyName]
       rs.MoveNext
     Next i

  End Function
Remou