Following on from last weeks DAO
recordset searching article, here we are reproducing the same
functionality with ADODB recordset objects. The concept is much the same,
just the approach is slightly different. Instead of DAO's FindFirst,
FindLast, FindNext and FindPrevious methods, ADO replaces all these with
the single method: 'Find'. The Find method takes a single argument (no
ANDs, ORs, etc.) as follows: 'Find first record satisfying search criteria
rsADO.Find "sex = 'Male'"
If rsADO.EOF Then
'no records matching search
Else
'successful search
Do While Not rsADO.EOF
'loop thru search results
rsADO.MoveNext
Loop
End If
If multiple records are returned, then the Find method positions the pointer
to the first record and the resultant records can be navigated using
rsADO.MoveNext, rsADO.MovePrevious, rsADO.MoveFirst and rsADO.MoveLast
methods as with unfiltered recordsets. However, if no records match the
search criteria, then rsADO.EOF will be True. The latter therefore
replaces the DAO NoMatch property, in determining the success of a search.
|