Results 1 to 2 of 2
  1. #1
    averagejoe is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    1

    Question Problem with DAvg function

    I'm relatively new to Access and have recently encountered a problem with the DAvg function.



    Click image for larger version. 

Name:	items table.jpg 
Views:	6 
Size:	46.2 KB 
ID:	9374

    Above is a table that should allow for better understanding.

    So, what I needed to do was to calculate the average prices based on Vendor Codes. Hence, the DAvg function. I used this expression:

    AL: DAvg("[Selling Price]","Item","[Vendor Code] = 'AL'")

    Upon running the query, I obtain the correct value for the average, but the problem lies in that it returns me the value multiple times - 10 times, to be exact.

    Click image for larger version. 

Name:	query.jpg 
Views:	9 
Size:	7.9 KB 
ID:	9376

    Could someone tell me why they return the result 10 times? Is there a problem with the expression; do I have to tweak something for it to work correctly; or am I using the wrong function to obtain the values I want?

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Here is a Query that returns the average selling price per vendor. It is called an aggregate query as it uses the aggregation function (the Sigma) in the QBE.

    Code:
    SELECT Table1.VendorCode, Avg(Table1.SellingPrice) AS AvgOfSellingPrice
    FROM Table1
    GROUP BY Table1.VendorCode;
    Here is a short tutorial on aggregations

    http://www.techonthenet.com/access/queries/index.php

    Scroll down to the group by section

    Alan

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

Similar Threads

  1. Problem with search function
    By sk88 in forum Access
    Replies: 2
    Last Post: 12-20-2011, 01:05 PM
  2. Concatenate function problem
    By Matt18 in forum Programming
    Replies: 1
    Last Post: 11-19-2011, 05:37 AM
  3. Problem with IIF function
    By Hulk in forum Forms
    Replies: 3
    Last Post: 03-20-2011, 12:59 PM
  4. VBA Function problem
    By smikkelsen in forum Programming
    Replies: 5
    Last Post: 07-16-2010, 07:46 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