I have a subform (continous mode) in my main form which is used to add some articles with description, amount and price. In the footer of this sumform is a textfield which sums up all the entries of the subform by using =sum([amount] * [price]). That works so far.
Each time when I add a new entry in the subform, this textfield gets calculated. Now I also want to have this sum in a textfield of my main form (which actually also is not a problem). In "AfterUpdate"-event of my combofield in the continuous form I write the value of the sum-textfield to my textfield in the mainform. This initially also worked perfectly.
But now (I have no clue what changed), my textfield in the mainform doesn't get the new value, because the vba code runs faster than the calculated textfield in my subform-footer calculates its new value. It always writes the old value to the mainform. I discovered the problem using brakepoints in my code. So the old value gets written to the mainform before access is finished calculating the sum of all subform-entries.
Here's the code which I use to write the value from my subform textfield to my mainform textfield:
Private Sub txt_Article_AfterUpdate()
Me.Refresh
Me.Parent!txt_Amount = Int(Me.txt_SumOfAmountsInContinuousForm * 20 + 0.5) / 20
End Sub
I hope the description of my problem is somewhat understandable. It's a bit difficult to describe it :) Is there a way to wait with my vba code until the sum-field has its new value calculated?
Thanks