Asking for help please.
Using an unbound text box in the footer of a subform I am trying to calculate a sum of values from a recordset in a continous form using a loop. Additionally, the field for which I am trying to sum is also an unbound field that holds an expression. dB file attached. From Home select Menu Items, click the hyperlink to view MenuItemDetails.
The example I am testing has three records and when I run the code below I see that it runs three times but instead of adding A + B + C for each record it is adding up A + A + A, or if I move focus to recordset B it will run B + B + B, same for recordset C. What am I missing here?
Using an unbound text box in the footer of a subform I am trying to calculate a sum of values from a recordset in a continous form using a loop. Additionally, the field for which I am trying to sum is also an unbound field that holds an expression. dB file attached. From Home select Menu Items, click the hyperlink to view MenuItemDetails.
The example I am testing has three records and when I run the code below I see that it runs three times but instead of adding A + B + C for each record it is adding up A + A + A, or if I move focus to recordset B it will run B + B + B, same for recordset C. What am I missing here?
Code:
Private Sub form_current()
Dim dblTotal As Double
With Me.RecordsetClone
If Not (.BOF And .EOF) Then
.MoveFirst
End If
Do Until .EOF
dblTotal = (dblTotal) + Nz(Me.txtComponentSubtotal.Value, 0)
'Debug.Print dblTotal 'View in Immediate Window "Ctrl +G"
.MoveNext
Loop
End With
Me.txtTotal_MenuItemCost = dblTotal
End Sub