Results 1 to 8 of 8
  1. #1
    rosscortb is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    52

    Query for adding totals from several tables

    Hi.



    I am trying to work out a query for adding the totals of each table then display the total over cost.

    One to many relationship.

    Personal details table
    Salary table
    2 enteries
    1/12/2014 £3549.50
    1/1/2015 £3549.50)

    Allowances Table-
    3 enteries
    1/12/2014 MISC £3036
    1/12/2014 COLA £1272.45
    1/12/2014 Fuel £2280

    So how do I get it to add total the salaries and the total of the allowances then display overall total?

    Thanks

    Ross

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Presuming each table also has Employee ID field.

    What level do you want to summarize? By pay period, year?

    Perhaps do two aggregate queries then join the queries.

    Or maybe do a UNION query the use that query as source for aggregate query.
    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
    rosscortb is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    52
    each employee does have a employee id field.

    At the moment I would like to have a query that look like this for example:
    1/12/2014 £3549.50
    1/1/2015 £3549.50
    Total: £7099
    1/12/2014 MISC £3036
    1/12/2014 COLA £1272.45
    1/12/2014 Fuel £2280
    Total: £6588.45
    Overal Total: £13,687.45

    At the moment I have a salary then one allowance on one line then a salary and a different allowance etc etc

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Can't do subtotals in query. This is what reports do with Grouping & Sorting features and aggregate calcs in group footers.
    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.

  5. #5
    rosscortb is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    52
    Thanks- do you know how I get over this issue "At the moment I have a salary then one allowance on one line then a salary and a different allowance etc etc"

    So the salary shows far too many times
    .
    Ross

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Possible options:

    1. build a report with groupings on employee ID and pay period with salary data in pay period group header and allowances in detail section, however, report sum of all pay period salaries will probably be wrong

    2. report/subreport arrangement

    3. union query
    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.

  7. #7
    rosscortb is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    52
    Hi Probably not going about it the right way but created a report for salary and allowances and then added them to Total Costing report which I like the look of. Is there any way of putting a criteria on a report as when I have added a new record(id 5) it goes into the report, is there a way to add a criteria asking for id number before running?
    See attached.

    Ross

    Click image for larger version. 

Name:	totals.jpg 
Views:	8 
Size:	89.6 KB 
ID:	19216
    Attached Thumbnails Attached Thumbnails SS1.jpg  

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Options:

    1. dynamic parameter in query (input popup or reference to control on form) - I don't do this

    2. code that applies filter criteria to report when it opens by referencing textbox on form - I do this with VBA
    DoCmd.OpenReport "report name", , , "ID=" & Me.ID
    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.

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

Similar Threads

  1. adding up totals in query
    By nightangel73 in forum Queries
    Replies: 3
    Last Post: 06-18-2014, 01:02 AM
  2. Replies: 1
    Last Post: 08-06-2013, 07:52 PM
  3. Query: Subtract totals from different tables
    By joannakf in forum Queries
    Replies: 3
    Last Post: 12-22-2011, 01:39 PM
  4. Adding totals to a form from a subform
    By Niki in forum Access
    Replies: 13
    Last Post: 05-13-2011, 12:17 AM
  5. Adding Totals to a query using queryDef
    By jrickels in forum Programming
    Replies: 7
    Last Post: 04-06-2010, 07:47 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