Bookmark Invalid

J

JimS

Using the following code, I get an Invalid Bookmark error. It appears to
happen on the last row of the filtered ADODB recordset on the "Movenext"
method...:

rstPickListDetail.Open "tblPickListDetail", cnn, adOpenDynamic,
adLockOptimistic
....
....
rstPickListDetail.Filter = "PLPicklistID=" & m_lngPicklistID
While Not rstPickListDetail.EOF
rstPickListDetail.Delete
rstPickListDetail.MoveNext
Wend
 
D

Douglas J. Steele

Why use a recordset for that? You'd be much better off simply issuing a
DELETE statement.

If you feel you must use a recordset, you need to start at the last record
and move forward to the first one:

rstPickListDetail.Filter = "PLPicklistID=" & m_lngPicklistID
rstPickListDetail.MoveLast
While Not rstPickListDetail.BOF
rstPickListDetail.Delete
rstPickListDetail.MovePrev
Wend

This is because when you delete the record, that record obviously can no
longer be the current row, so Access needs to move the current row pointer.
When you're going forward as you were, the pointer will end up at EOF when
you delete the last record in the recordset, so the MoveNext statement tries
to go past EOF.
 

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