Question Update jumps to the first record...?

zozew

Registered User.
Local time
Tomorrow, 07:46
Joined
Nov 18, 2010
Messages
199
Hi all,

How do i make Access stay on the current record if you press F5 for refresh or when the db refreshes automatically

thx
 
Ok looks great but where do i put the code if i want to have it run when somebody clicks F5 or the db automatically refreshes...on the onLoad of the Form? But then i need to change the bookmark everytime i step through records in the form to...right? Is there a "Change records" type event on a form?

thx
 
The current event fires on the change of records, and on load. I'm not sure how to detect the F5; I try to control when they requery.
 
Hi thanks, I played around with the onCurrent event but i still see a problem...
If the user is on record 5 and the db does a refresh it jumps back to record 1.

If i use the bookmark method on the onCurrent i can only set the bookmark to that record not load the form to the record bookmark..so I need a type of event when the db refreshes the form, and then set it so that when a user actually moves from record to record the db disregards the bookmark and lets the user move around....

Strange there is not a built in function/method/property to keep the user on the current record on a refresh....
 
Perhaps something like the following.

Turn on KeyPreview - you will find this under the Events tab of the form's Property Sheet.

Use this code:
Code:
Option Compare Database
Option Explicit

Private bMark As String


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 116 Then
        If Me.CurrentRecord <> 1 Then
            bMark = Me.Recordset.Bookmark
            Me.TimerInterval = 100
        End If
    End If
End Sub

Private Sub Form_Timer()
    Me.Bookmark = bMark
    bMark = vbNullString
    
    Me.TimerInterval = 0
End Sub
 
To the rescue again :D. Your solution takes care of the F5 problem, not to seem ungrateful....again, but what about having a general solution to the refresh..uhhmmm...lets call it symptom.

Having a general function catching the refresh and checking if the user or db is doing the refresh or/and if the user is browsing through records then disregarding the bookmark.

What i see is if there is a way to trigger a specific event on any type of refresh, one could create a function allowing any dev of access to keep their user on the current record no matter where the refresh stems from.

Anyway that's just me dreaming again :)

Thx so much for lessening my brain swelling

zozew
 
Having a general function catching the refresh and checking if the user or db is doing the refresh or/and if the user is browsing through records then disregarding the bookmark.
I don't see how the db automatically requeries your form without human intervention or some sort of timer event. Depending on your settings, it may refresh but a refresh is for the current record which is different from a requery.

If the requery was done by the user then you need to call Paul's code. Obviously you will only be able to trap the Requery if it was done via your own button and not via one of the built-in menus.
 
it may refresh but a refresh is for the current record which is different from a requery.

Ahaaaa...well my mistake, i thought the refresh done by the db was for the whole form (recodset).. And then i started thinking what would happen if it was a user instead of me inputting data in the form so i started to run worst case scenarios....and so on..

Okey now i get that the db will not requery or refresh the recordset unless its done by user interaction/timer code etc. Which in turn means that i can always trap that event and get them back to their current record if i want. I must have accidentally moved to another record when it happened to me.

Thanks for clearing that up for me :cool:
 
Okey now i get that the db will not requery or refresh the recordset unless its done by user interaction/timer code etc.
Just to clarify once more, the db will not requery, but it can refresh depending on the settings.
 

Users who are viewing this thread

Back
Top Bottom