When I need to copy from a recordset to an array, it is a little more efficient in order to have the ReDim array up to the size you want before, instead of ReDiming inside the loop.
Dim myIntArray() as Integer
Dim intDimension as Integer
rstSearchResult.Filter = "ID = " & blah
ReDim myIntArray(rstSearchResult.RecordCount - 1)
intDimension = 0
Do Until rstSearchResult.EOF
myIntArray(intDimension) = rstSearchResult!ID
intDimension = intDimension + 1
rstSearchResult.MoveNext
Loop
Please note that for RecordCount to work, you need to open the recordset as static.
rstSearchResult.Open "tblSearchResult", cnn, adOpenStatic
source
share