Value lookup by record number

E

Elwin

You're trying to retrieve a value based upon the record's
position in a recordset. I suggest using the form's
RecordsetClone object.

Dim var as Variant
Dim rst as DAO.Recordset
Set rst = Me.RecordsetClone
With rst
Do Until .EOF
If .AbsolutePosition = 5 Then
var = !MyField
Exit Do
End If
Loop
End With
rst.Close
Set rst = Nothing
 
A

Andy Korth

Ah- That's it!
Thanks a lot everyone! it works perfectly.
You have no idea how slow it was going through every
single of the 1400 records and running DLookup on each
one (10 times), checking to see if it matched the
selected criteria, and then writing it to an array if it
did.
This is waaaaaaaayyyyyyyy faster.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top