I want to calculate the average of a column or rows of project #1, project #2, etc.... and Adding a new column with the grade of the students ....like the picture..

Im new using visual basic. Thanks in advance. =D


[img]http://i41.tinypic.com/5z1xi.png[/img]

In order to calculate the average of a column in MS Access, you need to use the AVG function.

SELECT [Student ID], [First Name], [Last Name], and so on, AVG([Project#1]) AS avg1, AVG([Project#2]) AS avg2, AVG([Project#3]) AS avg3 FROM <table>

This will calculate the average of ALL rows, unless you also add a WHERE clause, in which you restrict which rows to calculate.

However, if you wish to have an average for each separate row then the query will be different.

SELECT [Student ID], [First Name], [Last Name], and so on, ((NZ([Project#1],0) + NZ([Project#2],0) + NZ([Project#3],0)) / 3) AS Average FROM <table>

The NZ function will test if the field contains NULL, and return a value of 0 if it does.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.