Results 1 to 2 of 2
  1. #1
    joebox8 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2011
    Posts
    13

    changing average Query

    hi..
    I want a Query to calculate the average of all the text boxes that have non-zero values in them. I have 16 text boxes that could potentially all be filled however i would like to be able to calculate only the average of what has been inputted.
    Im sure its fairly simple i just cant think of it.. I hope you know what im asking.. The calculation might be 8 values one time and 16 the next.
    My textboxes are named x1...x16.


    Any help would be great!

  2. #2
    joebox8 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2011
    Posts
    13
    I reckon its along these lines however this is a mess and doesnt work...

    SELECT x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16,
    ( x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 +x11 + x12 + x13 + x14 + x15 + x16) As Total,
    IIf (x1=0,0,1)+IIf (x2=0,0,1)+IIf(x3=0,0,1)+(x4=0,0,1)+(x5=0,0,1)+(x6 =0,0,1)+(x7=0,0,1)+(x8=0,0,1)+(x9=0,0,1)+(x10=0,0, 1)+(x11=0,0,1)+(x12=0,0,1)+(x13=0,0,1)+(x14=0,0,1) +(x15=0,0,1)+(x16=0,0,1) As Avg,
    IIF (Avg=0,0,Total/Avg) as Average)
    FROM LAC;

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

Similar Threads

  1. SQL query for average (2 tables)
    By JoshD in forum Queries
    Replies: 5
    Last Post: 04-13-2011, 06:12 AM
  2. Replies: 2
    Last Post: 07-14-2010, 06:10 AM
  3. Replies: 13
    Last Post: 05-28-2010, 11:57 AM
  4. Calculate average in a query
    By srbooth in forum Queries
    Replies: 1
    Last Post: 02-20-2010, 09:41 AM
  5. Rounding the Average in a Query
    By jakelufkin in forum Access
    Replies: 3
    Last Post: 06-19-2009, 08:31 PM

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