Results 1 to 2 of 2
  1. #1
    DICKBUTTONS is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Location
    NJ
    Posts
    3

    Question Averaging Percentages in a form


    Being a Novice at Access I'm not even sure this is possible......here is my question;

    I have a form that stores sub-tasks % complete (10 of them) that are part of one major task % complete.

    The major task % is calculated from the 10 sub-task percentages....what I would like Access to do is ignore the sub-tasks that are not used.

    Not all major tasks will have 10 sub-tasks....but my calculation will only work if all ten spots have a percentage listed even if I enter 0% it throws off the average.

    Is it possible to ignore the unused fields?? Here is my calculation field

    =([Text100]+[Text102]+[Text104]+[Text106]+[Text108]+[Text110]+[Text112]+[Text114]+[Text116]+[Text118])/10

    http://i170.photobucket.com/albums/u...S/screen-2.jpg

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If you judicously name your controls ...1 to ...10 then this function will do it.
    Warning >>> AIR CODE <<<
    Code:
    Private Function MyAverage() As Double
       Dim Accumulation As Double
       Dim Counter As Integer
       Dim Available As Integer
       For Counter = 1 To 10
          If Len(Me.Controls("YourName" & Counter) & "") > 0 Then
             ' This control has a value
             Accumulation = Accumulation + Me.Controls("YourName" & Counter)
             Available = Available + 1
          End If
       Loop
       If Available > 0 Then
          MyAverage = Accumulation / Available
       Else
          MyAverage = 0
       End If
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-03-2010, 02:47 PM
  2. Averaging with a conditional check
    By sarah in forum Queries
    Replies: 1
    Last Post: 10-05-2009, 05:11 AM
  3. Graph problems (displaying percentages)
    By bingobong62 in forum Access
    Replies: 0
    Last Post: 09-24-2009, 07:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums