Find Record after requery

C

Chris Kennedy

I am using a access adp project. I want to be able to delete a record,
requery the form and then make it go to the next record after the one
deleted. I have tried using bookmarks:

varAccount ID is the value of the primary key of the next record

Me.Requery
Dim rst As ADODB.Recordset
strCriteria = "[AccountID] = " & varAccountID & ""
Set rst = Me.RecordsetClone
rst.Find strCriteria
Me.Bookmark = rst.Bookmark
Set rst = Nothing

When I do this I get an error 3021 saying BOF or EOF is true

Alternatively I have tried using the find record method. Going to the next
record getting the value of the primary key, requerying the form, then
finding the record of the next record. But it won't find the record after
the requery, it just stays on the first record.

Any ideas? Regards.
 
M

Michel Walsh

Hi,


Adp or mdb? "" If "" it is an mdb, remove at once the line

Dim rst AS ADODB.Recordset


the clone is a DAO recordset, in that case, and you do not need to
"open" it, it is already open, for you to use, and you will use FindFirst,
not Find. You also capture the criteria BEFORE making the requery, in
general:


strCriteria="AccountID=" & NumericalValue
Me.Requery
Me.RecordsetClone.FindFirst strCriteria
Me.Bookmark=Me.RecordsetClone.Bookmark


and since you did not open the clone, you don't bother to close it either...
use, but don't abuse of it. :)



Hoping it may help,
Vanderghast, Access MVP
 

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