Results 1 to 4 of 4
  1. #1
    JimmD43 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Posts
    12

    Help calculating value based on field when primary key allows duplicates?

    I need to have my form calculate the average value of a field that is present on a form where duplicates for the primary key are allowed. For the sake of simplicity, I am using the example below with the table tblTravel and the form frmTravel.

    Primary Key: ID#


    Field: Miles

    ID#: 4465 Miles: 10
    ID#: 4465 Miles: 20
    ID#: 2310 Miles: 50
    ID#: 2310 Miles: 70

    I need to be able to calculate the average of 10 and 20 to get 15 and the average of 50 and 70 to get 60. Can anyone help?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Options include a Totals query using Avg, a recordset using a similar query, or DAvg(), depending on your specific needs.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JimmD43 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Posts
    12
    Quote Originally Posted by pbaldy View Post
    Options include a Totals query using Avg, a recordset using a similar query, or DAvg(), depending on your specific needs.
    DAvg() was exactly what I needed. Thank you so much!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Remove Duplicates Based on Criteria
    By suryaprasad in forum Access
    Replies: 0
    Last Post: 04-07-2011, 10:50 PM
  2. Replies: 4
    Last Post: 03-20-2011, 08:45 PM
  3. Replies: 1
    Last Post: 09-02-2010, 03:59 PM
  4. Calculating values based on Combobox value
    By BrianFawcett in forum Programming
    Replies: 1
    Last Post: 05-06-2010, 01:26 AM
  5. Replies: 1
    Last Post: 05-27-2006, 12:35 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