Full Version: After Update Event, cursor jumps from the record in which I made
UtterAccess Forums > Microsoft® Access > Access Forms
kcdoell
Hello:
I have a continuous form that displays records. In the AfterUpdate event of one of the fields, Binding_Percentage, I have the following code:
CODE
Private Sub Binding_Percentage_AfterUpdate()
'Updates the Total calculation in the control "SumGWP" and "SUMNWP"on the quick reference
'table on the Forecast form

    With Me![SumGWP] And Me![SumNWP] And Me![Sum50GWP] And Me![Sum50NWP]
    DoCmd.Requery
  
  End With
End Sub

Basically, in my field Binding_Percentage a user can select various choices from a drop down list I created. Depending on their choice, through the above mentioned code, I am refreshing various unbound fields on summary table that I created on the form. This all works great except that since I am doing a DoCmd.Requery the cursor jumps from the record in which I made the change jumps to the first record on the list.
So let’s say there were 5 rows each row representing a record on my form and I made a change on row 3, after the change the cursor would jump to row 1.
Obelieve this is happen because at the same time I must be requerying the form thus impacting the record source since it is set to a query I built.
How can I stop that from happen?? Any ideas??
Thanks,
Keith. dazed.gif
rsmccli
The Requery is causing your focus to go back to the first record. I snagged this from someone on here, maybe you can get it to work in your situation. It records the PK of whatever record you are currently on, then moves back to that record after the requery.
CODE
Dim lngKeyVal As Long
'Save the PK value for the current record
lngKeyVal = Me.txtPK
Me.Requery
'Move back to the original record
With Me.RecordsetClone
  .FindFirst "[ID] = " & lngKeyVal
  If Not .NoMatch Then
    Me.Bookmark = .Bookmark
  End If
End With

Odon't know if this will help, but I hope so. Good luck.
kcdoell
For those inquiring minds here was my solution:
CODE
Me.Dirty = False
    Me![SumGWP].Requery
    Me![SumNWP].Requery
    Me![Sum50GWP].Requery
    Me![Sum50NWP].Requery

Thanks for the ideas,
Keith. compute.gif
soitee_t
Thank you everybody >> such a good thing found this out.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.