16 December 2005

VBA: Reading from a recordset in an already loaded form

You can read directly from a recordset by using:


Call recordset.MoveFirst
While Not recordset.EOF
Debug.Print ("id=" & recordset!InstalmentRecID)
Call recordset.MoveNext
Wend

The movenext etc will actually make the selected item on the screen move.
To avoid this, you can use:


Set clone = recR.clone

Call clone.MoveFirst

While Not clone.EOF
Debug.Print ("id=" & clone!InstalmentRecID)
Call clone.MoveNext
Wend

Set clone = Nothing

which means that nothing is moved, and its faster.

No comments: