Resume search on next record

B

Bill

In the segment of code below, I'm looping through
an ADO recordset looking for match on both last
and first names. If the code locates a lastname in
the recordset but fails to match the second criteria,
the first name, then I want to continue searching on
the next record in the recordset.

The code fails on the Mark = rsAddrlst.Bookmark
with an error message to the effect that bookmarks
are not supported with the current recordset.

So, how else can I successfully resume searching
on the next record?

Thanks,
Bill
====================================


strTemp = "Lastname = " & Chr(39) & LName & Chr(39)
rsAddrlst.Find strTemp, 0, adSearchForward, 1 'first search

Do While Not rsAddrlst.EOF
Mark = rsAddrlst.Bookmark
If rsAddrlst![LastName] = LName And rsAddrlst![FirstName] = FName
Then
'We've found our "Hornet"
InRec = InRec & "; " & rsAddrlst![EmailHome] 'Append
correction
Exit Do
End If
rsAddrlst.Find strTemp, 1, adSearchForward, Mark
Loop

====================================
 
B

Bill

Turns out I didn't need to use bookmark, as the
recordset.find provides a record skip parameter.
I still don't know why some recordsets provide
bookmark functionality while other do not.
Bill
 
B

Baz

From help:

There are four different cursor types defined in ADO:
Dynamic cursor - allows you to view additions, changes, and deletions by
other users; allows all types of movement through the Recordset that doesn't
rely on bookmarks; and allows bookmarks if the provider supports them.
Keyset cursor - behaves like a dynamic cursor, except that it prevents you
from seeing records that other users add, and prevents access to records
that other users delete. Data changes by other users will still be visible.
It always supports bookmarks and therefore allows all types of movement
through the Recordset.
Static cursor - provides a static copy of a set of records for you to use to
find data or generate reports; always allows bookmarks and therefore allows
all types of movement through the Recordset. Additions, changes, or
deletions by other users will not be visible. This is the only type of
cursor allowed when you open a client-side Recordset object.
Forward-only cursor - allows you to only scroll forward through the
Recordset. Additions, changes, or deletions by other users will not be
visible. This improves performance in situations where you need to make only
a single pass through a Recordset.

So, whether a recordset supports bookmarks is a function of (i) the provider
and (ii) how you opened the recordset. It is not possible to determine
either of these things from the code snippet that you posted.


Bill said:
Turns out I didn't need to use bookmark, as the
recordset.find provides a record skip parameter.
I still don't know why some recordsets provide
bookmark functionality while other do not.
Bill

Bill said:
In the segment of code below, I'm looping through
an ADO recordset looking for match on both last
and first names. If the code locates a lastname in
the recordset but fails to match the second criteria,
the first name, then I want to continue searching on
the next record in the recordset.

The code fails on the Mark = rsAddrlst.Bookmark
with an error message to the effect that bookmarks
are not supported with the current recordset.

So, how else can I successfully resume searching
on the next record?

Thanks,
Bill
====================================


strTemp = "Lastname = " & Chr(39) & LName & Chr(39)
rsAddrlst.Find strTemp, 0, adSearchForward, 1 'first search

Do While Not rsAddrlst.EOF
Mark = rsAddrlst.Bookmark
If rsAddrlst![LastName] = LName And rsAddrlst![FirstName] = FName
Then
'We've found our "Hornet"
InRec = InRec & "; " & rsAddrlst![EmailHome] 'Append
correction
Exit Do
End If
rsAddrlst.Find strTemp, 1, adSearchForward, Mark
Loop

====================================
 

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