Sql – Average, Count, etc of entire column of table in SQL Query or as Function in VBA to Display result in Form

ms-accesssqlvba

I need to calculate Count, Average and a couple other things of a column as a result of a Query and then put the result in a text box in a form.

I was thinking about either implementing it in the Query and putting the results in a column or something like that, OR use a VBA function to calculate it; however I don't know how to calculate this for an entire column in VBA.

Any suggestions/examples?

Best Solution

Actually I found that this is very easy in VBA. I didn't want to add another field to my Query so I did this:

Forms!MyForm!AvgTextBox = Avg([mytable.values2Baveraged])
Forms!MyForm!CountTextBox = Count([mytable.values2Bcounted])

This calculates the function on the entire column. This worked perfectly just in case anyone cared.

Related Question