Solved Requery underlying form, but retain bookmark (1 Viewer)

Glad to help I only signed up to point that out.

Often what we think we are doing is not actually what we told the system to do and it always pays off to take a second to stop and examine our actual tradjectory vs intended direction.


Thanks @Xyloz! I am one of those people who had a convoluted way of refreshing my form after I wanted to remove an item from a step. I am trying your simple solution and testing is going well. I appreciate the explanation that we want to refresh the data and not the form. Makes sense.
 
Glad to help I only signed up to point that out.

Often what we think we are doing is not actually what we told the system to do and it always pays off to take a second to stop and examine our actual tradjectory vs intended direction.
I've had this problem as well - trying to bookmark a spot, requery, then return to that spot. I had the requery on the form level, so based on your advice here, I tried dropping it to the recordset level, and no change. It still barfs with an 'Invalid bookmark' error message when I try to return to that previously saved bookmark.
Code:
Dim bkm$
With sfSynonymika.Form.Recordset
    If .RecordCount > 0 Then
        bkm = .Bookmark
        .Requery
        .Bookmark = bkm
    End If
End With
Any other ideas?
 
Bookmarks are recordset specific pointers so if you requery those bookmarks are invalid. So that error is expected and guaranteed. I did not read the entire 3 year old thread but assume this is fully covered.

On easy way is to first save the primary key of the current record, then requery, then use a findfirst and move back to that value

Code:
Dim PK as long
PK = me.somePKField
with sfSynonymika.Form.Recordset
   .requery
   .findfirst "SomePkField = " & PK
End With

However if you simply requery the
 
Now I reread the thread and of course this was covered, and in fact it was me.
I would not resurrect this thread because this is one of the stupidest threads I have ever read. The OP seemed to be trolling.
 
Now I reread the thread and of course this was covered, and in fact it was me.
I would not resurrect this thread because this is one of the stupidest threads I have ever read. The OP seemed to be trolling.
I wondered. It seemed like a reasonable thought at first - requery just a recordset instead of an entire form, but it seeems to be as you say - requery blows away bookmarks. Not always though, which is how this code often makes it into production. Sometimes a bookmark DOES still work after a requery - apparently the new bookmarks sometimes happen to match an old one. I have deployed code that contains bookmark references, and sometimes it was weeks down the road before someone started complaining. I've gotten much more careful about where I use them. Part of the problem is that I have no idea what info a bookmark actually contains, although it is clearly not as sophisticated as a file hash. But using a unique identifier and a .Find is clearly the way to go, if you have a Requery in the process.
 

Users who are viewing this thread

  • Back
    Top Bottom