Forum Discussion
JasonCanady
Jul 27, 2026Tin Contributor
Access Query Problem
Good afternoon. I have been trying to track down a very strange error that my database has thrown for the first time ever... the query performs a complex math equation based on temperature, chlorine ...
- Jul 28, 2026
You are comparing strings, not numeric values, and all your field values seem to be text, thus should be converted. Try this:
SELECT CT_ALL.CTDate, CT_ALL.[12AM], CT_ALL.[4AM], CT_ALL.[8AM], CT_ALL.NOON, CT_ALL.[4PM], CT_ALL.[8PM], CT_ALL.High, CT_ALL.CT1_Time, CT_ALL.Peak, CT_ALL.CT2_Time, CT_ALL.C, CT_ALL.T, Val(Format(CDbl(Nz([C], 1)) * CDbl([T]), '#.0')) AS CxT, CT_ALL.Sed_Cl2, CT_ALL.Sed_T, CT_ALL.Temp, CT_ALL.pH, CT_ALL.[3 Log], CT_ALL.Log, Val(Format(CDbl(Nz([C2], 0)) * CDbl([T2]), '#.0')) AS CxT2, CT_ALL.Sed_Cl2 AS C2, CT_ALL.Sed_T AS T2, IIf( [Temp_1] = '--', Null, IIf( Val([temp]) < 12.5, (0.353 * 0.5) * (12.006 + 2.71828183 ^ (2.46 - 0.073 * Val([Temp]) + 0.125 * Val([C]) + 0.389 * Val([pH]))), (0.361 * 0.5) * (-2.261 + 2.71828183 ^ (2.69 - 0.065 * Val([Temp]) + 0.111 * Val([C]) + 0.361 * Val([pH]))) ) ) AS CT_Required, Nz([Temp], '') AS Temp_1, CT_ALL.C AS C1, IIf([CxT] > [Ct_Required], 'YES', 'NO') AS ClearwellMet, IIf([CxT_Sum] > [CT_Required], 'YES', 'NO') AS Met_Overall, IIf( [temp_1] = '--', Null, IIf( Val([temp]) < 12.5, (0.353 * 3) * (12.006 + 2.71828183 ^ (2.46 - 0.073 * Val([Temp]) + 0.125 * Val([C]) + 0.389 * Val([pH]))), (0.361 * 3) * (-2.261 + 2.71828183 ^ (2.69 - 0.065 * Val([Temp]) + 0.111 * Val([C]) + 0.361 * Val([pH]))) ) ) AS 3Log FROM CT_ALL WHERE CT_ALL.CTDate Between [forms].[FiltrationPlant].[StartDate] And DateAdd('m', 1, ([Forms].[FiltrationPlant].[StartDate])) - 1;
Tom_van_Stiphout
Jul 28, 2026Steel Contributor
Interesting problem.
To debug it, I would rewrite the 3Log expression in VBA, so it is much easier to debug. I'm assuming that is the column you are referring to with "the formula".
Also, can you paste the text of the SQL statement into a reply?
Uploading the Excel file will be helpful as well.