Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating text box value

Status
Not open for further replies.

Dogss

Technical User
Oct 17, 2006
4
AU
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
 
Try DSum:

[tt]DSUM("Temp","qry_final","[Hour] Between '" & StartTime & "' AND '" & FinishTime & "' AND Code = '" & ADL & "' AND [Month] = 'Jan'"[/tt]

GROUP BY is not relevant.

I am a little puzzled that Hour is text (') rather than date/time (#).

You may wish to look at:
List of reserved words in Access 2002 and Access 2003
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top