# Calculating Averages in Access



## davidclifford (Jul 6, 2004)

Hi,

I'm trying to create a table which shows the average salary level for about 90 countries, using DAvg to calculate the averages based on data from a separate table which contains the raw data for all countries.

So, I have tbl_source, with fields: "country", "job id" (as primary key), and "salary" currently 920 records, and tbl_results, with "country" and "average salary level".

At the moment I am using the following line in the "Update to" line of an update query 

_DAvg([tbl_source].[NetSalary],"tbl_source",[tbl_results].[country]=[tbl_source].[country])_

But this is only returning the last value in "tbl_source" for each country rather than calculating the average. Also, the pop-up message says that it is updating 920 records (the number of records currently in "tbl_source")

Can anyone see a flaw in the update query (or am I using the function in the wrong way?)

Thanks for the help

David


----------



## elf (Jul 19, 2002)

I'm not real good with access, but wouldn't it be 


```
DAvg([tbl_source].[salary]
```
 instead of NetSalary?


----------



## davidclifford (Jul 6, 2004)

Ah, good point, the actual field title is NetSalary, not Salary as I stated in my original message. But the query _is_ pointing at the correct field.

I have put double quotation marks around the "[tbl_source].[NetSalary]", which now calculates the average of all the records in the field. The criteria at the end is now ignored.

DAvg([tbl_source].[NetSalary],"tbl_source",[tbl_results].[country]=[tbl_source].[country])


----------

