Full Version: Summing a Field
UtterAccess Discussion Forums > Microsoft® Access > Access Q and A
tair23
I have a report, with detail lines. In each detai line I have a multiplier and a base amount. I multiply the 2 numbers and put them in a textbox. This works great. However I need to total the amounts in the text box at the bottom of the report. =Sum([text42]) Doesnt work and it asks me to pop u late text 42 via a pop up box. Text42 is the text box that holds the answer to the multiplier and the base amount being multiplied. I figure you can't sum a calculated box. I am sure there is way to do this thanks for your help.
fkegley
This might work:

In the Control Source of the text box in the report footer:

=Sum([Field1] * [Field2])

where Field1 and Field2 are the fields being used to get the value in text42.
tair23
=Sum(([text36]*[SURFACETONS])+([text36]*[basetons]))

Is my code. Now Text36 is an unbound textbox that has Code written behind it to find the multiplier and hold it for each record.

It does not display anything and it ask me to input text36 with a pop up box
tair23
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim varX As Variant
varX = DLookup("[pavingrate]", "tbl_PavingRatesByYear", "[pavingyear] = " _
& Reports!rpt_PavingArchive!Text38)

Text36 = varX


End Sub

Is how text36 gets its multiplier
tair23
Could I add a text box on each record that would keep a running total?
fkegley
Yes you can do that.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.