Requery

G

gr

Hello!
Is there any way to requery a form and then return to the
last visited record(last current record)?

Current record where code starts ---> Requery form, now
current record is first record ---> Return to original
current record where code started.

I was using the bookmark property with no luck..

strBookmark = Me.Bookmark
..... ....
..... ....
..... ....
Me.Requery
Me.Bookmark = strBookmark

Error 3159: Not a valid bookmark... =/

thx.
 
R

Rick Brandt

gr said:
Hello!
Is there any way to requery a form and then return to the
last visited record(last current record)?

Current record where code starts ---> Requery form, now
current record is first record ---> Return to original
current record where code started.

I was using the bookmark property with no luck..

strBookmark = Me.Bookmark
.... ....
.... ....
.... ....
Me.Requery
Me.Bookmark = strBookmark

Error 3159: Not a valid bookmark... =/

Bookmarks are reset when you requery the form. You need to store the
Primary Key value of the current record, issue the requery, and then use
the stored PK value to return to the record you were on.

curRecord = Me.PKField
Me.Requery
Me.RecordsetClone.FindFirst "[PKField] = " & curRecord
Me.Bookmark = Me.RecordsetClone.Bookmark

Note that this is very inefficient on large RecordSets where you should be
restricting the rows to the record you are interested in anyway.
 

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