Forum Discussion
Refresh Sum in form
- Mar 17, 2022Changes to records are not saved until you move off that record or click Enter (which has the same effect). That behaviour is by design in Access databases.
Your code will not work - the form has not been updated whilst you remain on the record.
Once you leave the record, the update occurs automatically with no need to requery, recalc, refresh or even repaint!
Tony2021 As Colin pointed out, you don't need to do anything except move focus to another record. However, if you have a business need to see the updated sum without moving to a new record, you can force the save by adding:
Me.Dirty = False
to your code before refreshing the form.
Hello, thank you for the response.
I understand that maybe this cant be done.
George, I tried Me.Dirty as instructed but it still did not refresh teh sum. I also tried to save the record. i also added it to the form's On Dirty Event.
Let me know if any other suggestions or if I should forget about this.
- arnel_gpMar 18, 2022Iron Contributoron the "Column" you are Totalling, add code to it's AfterUpdate event to force save the record.
private sub theColumnName_AfterUpdate()
Me.Dirty = False
end sub- Tony2021Mar 18, 2022Iron Contributor
Hi Arnel,
That unfortunately didnt seem to work either.
I tried Me.Dirty = False first on that column I am summing and then I added all the other stuff (refresh, recalc save record...) thinking that might refresh it but that didnt work either.
The column I am summing is txtCAWCCalc. Its a calculated column.
Let me know if I am not following.
- arnel_gpMar 18, 2022Iron Contributoraside from Me.Dirty = False,
you can also add code to Requery the Control.
Me.Dirty = False
Me!txtCAWCCalc.Requery