The hidden Collect method of the Recordset object

The ADO Recorset object exposes a hidden, undocumented member: the Collect property. This property is functionally similar to the Field’s Value property, but it’s faster because it doesn’t need a reference (explicit or implicit) to the Field object. You can use this property by passing a numeric index or a field’s name, as in:

Dim rs As New ADODB.Recordsetrs.Open "authors", "DSN=pubs"    ' reference by field's namefirstName = rs.Collect("au_fname")' reference by field's indexrs.Collect(2) = "John Doe"

Under ADO 2.5, the Collect property appears to be about 30% faster than the standard way to refer to a field’s value.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: