Full Version: Summing A Formula Field
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
Ladyd030400
Hello,
I'm hoping that someone can steer me in the right direction as I'm still trying to figure out how Access works. I have created a report and need to insert a formula to sum a particular text box (which has this formula in it: IIf(Count([Job Req No])>1,IIf((Sum(IIf([Race]<>"White",1,0)))>0,1,0),0)) . The formula basically says this: for every job requisition that has more than one candidate or more than one job requisition number (whether different or not), i'm asking to return a 1 if it's a minority race. If there are no minorities return a zero and if there is only 1 job req return a zero. Now for every job requistion number that has a 1 in this field i would like to add a total (summing all of the "1"s). If i put =Sum(IIf(Count([Job Req No])>1,IIf((Sum(IIf([Race]<>"White",1,0)))>0,1,0),0)) it gives me an error message "Cannot have aggregate function in expression". I'm not sure how else to go about summing these....HELP PLEASE!!

Thank you in advance
doctor9
Ladyd030400,

Whenever you want to Sum a formula like this, move the formula from the textbox's controlsource and into the report's driving query as a calculated field. Then you can simply have:

=Sum([CalculatedFieldName])

in a textbox on your report.

Hope this helps,

Dennis
Ladyd030400
Dennis,
thank you so much. it worked brilliantly!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.