I am trying to sum values from a query and enter the summation into a text box.
I am using the following code;
txt_Sum.ControlSource= "SELECT SUM(qry_final.Temp) FROM qry_final WHERE qry_final.Hour>= '" & StartTime & "' AND qry_final.Code = '" & ADL & "' AND qry_final.Hour <= '" & FinishTime & "' AND qry_final.Month = ""Jan"" GROUP BY qry_final.Code, qry_final.CityName, qry_final.Month"
However this is giving me a NAME error in the text box. If I dump the same code into a list box using row source instead of control source and use SELECT DISTINCT ROW instead of just SELECT it works fine.
Thanks.
M
I am using the following code;
txt_Sum.ControlSource= "SELECT SUM(qry_final.Temp) FROM qry_final WHERE qry_final.Hour>= '" & StartTime & "' AND qry_final.Code = '" & ADL & "' AND qry_final.Hour <= '" & FinishTime & "' AND qry_final.Month = ""Jan"" GROUP BY qry_final.Code, qry_final.CityName, qry_final.Month"
However this is giving me a NAME error in the text box. If I dump the same code into a list box using row source instead of control source and use SELECT DISTINCT ROW instead of just SELECT it works fine.
Thanks.
M