Strange behaviour with rs.Find (ADODB)

M

Mark

Hi

Using Access XP with MSDE (2000) backend.

I am opening a form and naavigating to a specific record (based on the
openargs, not conditions as when I use conditions an activex control
displays in the wrong place - but thats another story).
Anyway, there are no filters on the form and I have stepped through the code
to prove that a) the recordset is populated and b) the record I'm looking
for exists in that recordset. However, I keep getting an error on the last
line "Me.Bookmark = rs.Bookmark" saying "Error 3021: Either BOF or EOF is
True, or the current record has been deleted". If I step back up to "Set rs
= Me.RecordsetClone" and run from there the form loads ok at the correct
record...?

findSubjectID = CLng(Me.OpenArgs)
Set rs = Me.RecordsetClone
rs.MoveLast
rs.MoveFirst
rs.Find "subjectID=" & findSubjectID
Me.Bookmark = rs.Bookmark

This happened last night and I'm not in work today so I can't play, but...
Before leaving I tried to take a copy of the backend. I was unable to stop
MSDE and had to reboot the machine first. Is it possible this is just down
to a glitch on the server?

Cheers

Mark
 
S

Sylvain Lafontaine

Instead of using MoveLast, try resyncing the new recordset to the old one
with « rs.AbsolutePosition = f.Recordset.AbsolutePosition » or make sure
that rs.MoveLast followed by rs.MoveFirst are actually doing something. A
good idea would be to use the Debug.Print or the Msg command to display the
values of AbsolutePosition to see what's happens. (And don't use the
debugger for this, as the later might affect the execution of code on some
occasions.)

Also, I always use « Option Compare Binary » at the beginning of any module
using bookmark. Not sure if it's still a good idea with Access 2002 or 2003
but it cannot hurt.

Did you try adding the test "If (Not rs.BOF and Not rs.Eof) Then ..." before
the line "Me.Bookmark = rs.Bookmark"?

Finally, there have been some rapports of bug for Access XP ADP in the past
since Service Pack 2 for Windows has been out. Might be a good idea to try
with A2003 instead.
 

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