Access VBA Macros

Home » Uncategorized » Loop through all records of a table

Loop through all records of a table

Sub loop_all_records()
Dim I As Long
Dim rs As Recordset
‘ change sample as per ur table name
Set rs = CurrentDb.OpenRecordset(“sample”, dbOpenDynaset)
Do While Not rs.EOF
For I = 0 To rs.Fields.Count – 1
MsgBox rs(I)
Next
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: