MS Access: Simple Recordset example

Access VBA developer must know, how to play with a recordset. A recordset is a collection of data which stores a group of records in a database. These records could be the result of a query or the contents of an individual table. Here is a very basic recordset program
Private Sub Command0_Click()
Dim strSQL As String
Dim rs As Recordset
Dim n As String

strSQL = "SELECT DISTINCT id FROM mytable"

Set rs = CurrentDb.OpenRecordset(strSQL)
rs.MoveFirst

Do While Not rs.EOF
    n = rs!id
    MsgBox n
    rs.MoveNext
Loop
End Sub
For more detailed explanation check the below link
http://allenbrowne.com/ser-29.ht
http://www.utteraccess.com/wiki/index.php/Recordsets_for_Beginners

No comments:

Post a Comment