Form Calculations Generating Errors - Iff Sum (1 Viewer)

Wag2016

Registered User.
Local time
Yesterday, 19:30
Joined
Mar 5, 2016
Messages
24
Hi everyone,

Thanks for taking a look at my question. I am sure it is an easy fix but my stubborn eyes are not seeing the problem and I have been staring at it so long that I knew to come right here.

Attached: Stripped database, relations, jpg of the form

I have a simple database tracking quoted expenses. One form, two queries. You create a quote, add expenses and that's it.

CALCULATIONS
In the Textbox called SUMTOTAL (calculates Total)
Code:
=Sum([TOTAL])

In the Textbox called TRANS (If the category is 1 then Sum)
Code:
=Sum(IIf([CATEGORY]="1",[SUMTOTAL],0))

In the Textbox called TRANSAVG (Average)
Code:
=([Trans]/[SUMTOTAL])


ERRORS:

#Type! error for the TRANSAVG
#Error for TRANS and SUMTOTAL

If I take out TRANS and TRANSAVG then SUMTOTAL is just fine.

Are the formulas right? Where am I going wrong here?

THANK YOU!
Laura


View attachment Expense.zip

database.JPG

form.jpg
 

June7

AWF VIP
Local time
Yesterday, 15:30
Joined
Mar 9, 2014
Messages
5,465
Aggregate functions must calculate fields, not controls.

Why is Sum([Total]) in header and footer in 3 controls? Why Sum the Sum([Total])?

Category is a number field in tblMainExpensesDesc. Use the ID value without quote marks.

Possibly should be:

=Sum(IIf([CATEGORY]=1,[TOTAL],0))

#NAME? error is because of reference to SubTotal and there is no field/control named SubTotal. There is SUMTOTAL.
 
Last edited:

Wag2016

Registered User.
Local time
Yesterday, 19:30
Joined
Mar 5, 2016
Messages
24
Changes made and it worked - thank you for your help!
 

Users who are viewing this thread

Top Bottom