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!
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.
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- Tony2021Mar 18, 2022Iron ContributorYes it is a subform. I added the Me!txtCAWCCalc.Requery to all the events above but didnt refresh.
Unless there is a trick some other crafty trick maybe ISLADOGS post is best advice (it cant be updated). Not sure if I could close the subform and reopen somehow (with screen updating off) but might be more of a headache than its worth. Let me know if any other suggestions. thank you
- arnel_gpMar 18, 2022Iron ContributorIs it a subform?
- isladogsMar 18, 2022MVP
Using Me.Dirty=False has exactly the same effect as what I stated in post #2.
Doing that will also move the focus to another record (or field) and so the total will be updated
None of the other code you posted is neededThat applies whether or not you are using a calculated field. You MUST move to a different record to update the calculated field total