Average with Blanks in Access 2010

merk_3

New member
Local time
Today, 07:04
Joined
Nov 29, 2012
Messages
1
Hey everyone,

I am trying to find an average of four fields in either a form or query. Basically I have figures for [Grade 1], [Grade 2] but [Grade 3] is an empty field. I need to include all three field because there are sometimes 3 grades, but a majority are 2 grades.

I am at a complete loss as to how to do this and would appreciate any help I can get!


Thanks for any help guys and girls!

Merk
 
The simplest approach, if I'm understanding you correctly, is just
Code:
    If IsNull(Grade 3) Then
        txtAverage = (Grade 1 + Grade 2) / 2
    Else
        txtAverage = (Grade 1 + Grade 2 + Grade 3) / 3
    End If

It's not terribly robust though. You can put this as the OnClick event of a button or whatever you want.
 

Users who are viewing this thread

Back
Top Bottom