I want the first and last entries for Location from a recordset depending on field "Key" (which is passed in).
My plan was to move backwards until Key Changes then likewise forward to get the last.
The problem is EOF and BOF. If they're true I've lost rz!MyCount. Have tried some things, like Do While and Exit Do but get the same result. How might this be handled properly? Thanks.
My plan was to move backwards until Key Changes then likewise forward to get the last.
Code:
Key = rz!Location
Do
rz.MovePrevious
'Debug.Print rz!MyCount
Loop Until (rz.BOF) Or (rz!Location <> Key)
rz.MoveNext
theStart = rz!MyCount
Do
rz.MoveNext
'Debug.Print rz!MyCount
Loop Until (rz.EOF) Or (rz!Location <> Key)
rz.MovePrevious
theEnd = rz!MyCount