Results 1 to 4 of 4
  1. #1
    rodcwashoe is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    2

    Cool Calculate value in a query that uses data from different records

    Hi,

    I'm trying to create a calculated field that uses data from different records. For example: There is a record created in the transaction table for each item sold that contains the customerID, item and amount. I can create a report that totals the amount and calculates a fee by customerID , but I need to create a query or a table from a query that will provide the total amount for each customer in a single field that can be used to calculate a fee that is base upon the total amount.



    I've been trying to work this out for several days and my brain is tired.

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Having a record pull data from other record(s) of same table can be tricky. Options:

    1. subquery, review http://allenbrowne.com/subquery-01.html

    2. domain aggregate functions (DSum, DAvg, DCount, etc) - search Access Help

    3. VBA function called by query

    4. build a report using Sorting & Grouping features and do summary calcs in report and group sections header/footer
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Yes, in your 1st qry..Qry1 it would be the list of data in the trans. tbl. (you can sum this too if needed by select [CUST ID] , Sum([Amt]) as Total ).
    Now the fees, there's easy and hard ways...
    1. if its a simple calc (say percent), add another field select [CUST ID] , Sum([Amt]) as Total , Sum([Amt])*0.2 as Fee

    2. if it is a table lookup you must add the table to the query, and possible ranges.

    3. you could make a Function() ( instead of lookup table), write your own function to return the fee value , given the Amt value

  4. #4
    rodcwashoe is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    2
    Thanks June7 and Ranman256 for the quick response.

    I will look at your suggestions and try to make it work. Will let you know.

    Thanks

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

Similar Threads

  1. calculate the Average of certain records
    By mazides in forum Queries
    Replies: 1
    Last Post: 10-16-2013, 11:10 AM
  2. Replies: 2
    Last Post: 09-04-2013, 09:48 AM
  3. Replies: 1
    Last Post: 02-16-2013, 09:25 AM
  4. Replies: 7
    Last Post: 04-22-2012, 02:28 PM
  5. Calculate Time and Display Records
    By w2vijay in forum Reports
    Replies: 1
    Last Post: 02-12-2010, 01:58 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