Hello,
I need to find a way to use normal symmetric rounding (always rounds .5 up) instead of the Bankers Rounding that access defaults to when using the round() function. My end goal is to have a query/report with 3 columns; one column for Reg_Hrs*Reg_Rate, one for OT_Hrs*OT_Rate, and a grand total column that sums the two.
I found a post on another forum recommending that I use the formula: Format(number_to_Format,"#.00"). This works in my query for this expression:
"Sum(IIf(IsNull([Lbr_TS_Dtl]![Reg_Hrs]),0,Format([Lbr_TS_Dtl]![Reg_Hrs]*[lbr_Ts_Dtl]![Reg_Rate],"#.00")))"
However, when I try to use it to sum up the totals for Regular rate and Overtime Rate using this:
Sum(IIf(IsNull([Lbr_TS_Dtl]![Reg_Hrs]),0,Format([Lbr_TS_Dtl]![Reg_Hrs]*[lbr_Ts_Dtl]![Reg_Rate],"#.00")) +
IIf(IsNull([Lbr_TS_Dtl]![OT_Hrs]),0,Format([lbr_TS_Dtl]![OT_Hrs]*[lbr_ts_Dtl]![Overtime_Rate],"#.00")))
I get the error:
The expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.
I get the same error when I put the Format() formula on the outside of the IIF statement.
I also tried taking out the Sum() and changing the "Total:" field from Expression to Sum and I got a bunch of other errors doing that.
Is there:
A) Some way to fix my expression
B) A way to "Assign parts of the expression to variable" as per the error message's reccomendation
C) A way to sum the Reg and Overtime columns without getting the "Subqueries cannot be used...." error
D) a pre-made vba rounding function that I could put in here? (I am starting to think that shoul have been my first choice however, I have never created a vba function before so I have avoided this solution)
Thank you in advance!
Canuck_1
I need to find a way to use normal symmetric rounding (always rounds .5 up) instead of the Bankers Rounding that access defaults to when using the round() function. My end goal is to have a query/report with 3 columns; one column for Reg_Hrs*Reg_Rate, one for OT_Hrs*OT_Rate, and a grand total column that sums the two.
I found a post on another forum recommending that I use the formula: Format(number_to_Format,"#.00"). This works in my query for this expression:
"Sum(IIf(IsNull([Lbr_TS_Dtl]![Reg_Hrs]),0,Format([Lbr_TS_Dtl]![Reg_Hrs]*[lbr_Ts_Dtl]![Reg_Rate],"#.00")))"
However, when I try to use it to sum up the totals for Regular rate and Overtime Rate using this:
Sum(IIf(IsNull([Lbr_TS_Dtl]![Reg_Hrs]),0,Format([Lbr_TS_Dtl]![Reg_Hrs]*[lbr_Ts_Dtl]![Reg_Rate],"#.00")) +
IIf(IsNull([Lbr_TS_Dtl]![OT_Hrs]),0,Format([lbr_TS_Dtl]![OT_Hrs]*[lbr_ts_Dtl]![Overtime_Rate],"#.00")))
I get the error:
The expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.
I get the same error when I put the Format() formula on the outside of the IIF statement.
I also tried taking out the Sum() and changing the "Total:" field from Expression to Sum and I got a bunch of other errors doing that.
Is there:
A) Some way to fix my expression
B) A way to "Assign parts of the expression to variable" as per the error message's reccomendation
C) A way to sum the Reg and Overtime columns without getting the "Subqueries cannot be used...." error
D) a pre-made vba rounding function that I could put in here? (I am starting to think that shoul have been my first choice however, I have never created a vba function before so I have avoided this solution)
Thank you in advance!
Canuck_1