Forum Discussion
Refreshing calculated controls
Storming You can use the AfterUpdate events of the controls in the subform.
Because you want to call the same requery from multiple controls, you'd probably best make it a separate sub that can be called from those control events. Something like this, using your own control names, of course.
Public Sub RefreshMainForm()
With Me
.Parent.FirstUnboundControlNameGoesHere.Requery
.Parent.SecondUnboundControlNameGoesHere.Requery
.Parent.ThirdUnboundControlNameGoesHere.Requery
End With
End Sub
- StormingApr 03, 2020Brass Contributor
Hi George, many thanks for that but....
The calc controls are based on the following code when the form is loaded:-
[Forms]![Accounts open maintenance]![Tot Gross] = DSum("[Gross Amount]", "Accounts open query", "[Type]='Income'") - DSum("[Gross Amount]", "Accounts open query", "[Type]='Expenditure'")
How do I reset the control to the filtered data?
- George HepworthApr 03, 2020Iron Contributor
Call that code by referring to the Open Form sub. You'll have to change it from a Private to a Public Sub
OR, move that code to the public sub as described above.
- StormingApr 03, 2020Brass Contributor
Hi, the initial calc works from the query.
I do not think after the user performing a filter on the initial data that the same recalc can be used as it points to the original data when opening the form and not the filtered data