Results 1 to 8 of 8
  1. #1
    kurazy is offline Novice
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    7

    Unhappy Calculations with values in previous record(s)

    I have a database where I need to record student data, specifically marks and absenteeism. The marks are recorded each term as a running total. I have a final mark which needs to be equal to the 4th term mark.



    I also need to record the number of days absent each term with a total at the end of the year.

    My problem is that the term 4 mark is a in the previous record and the total days absent needs to be the total of the previous 4 records (term 1 - 4).

    I using a create table query and an update query but that was a no go.
    Attached Files Attached Files

  2. #2
    kurazy is offline Novice
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    7

    Unhappy

    My apologies if I wasn't clear in my post. I also simplified my sample database.

    In tblMarks record 5, the mark has been set as the same as the previous mark.

    Mark Term
    42 1
    32 2
    45 3
    65 4
    65 5 (This is the final mark that needs to be equal to term 4 mark)


    In tblAbsent record 5, the number of days absent is equal to the sum of the previous 4 days absent.

    Absent Term
    2 1
    2 2
    4 3
    2 4
    10 5 (Sum of terms 1 to 4)

    The year is broken up into 4 terms.

    I hope this clarifies things.
    Attached Files Attached Files

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743
    You may get some ideas on database and table design from this free data model.
    And the associated business facts here.

  4. #4
    kurazy is offline Novice
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    7
    Thanks for the reply. It doesn't really help me though. My problem isn't with the table design.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You don't perform those summaries in a query. That's what reporting is for. Is there a specific reason you want to do this in a query rather than on a report?

  6. #6
    kurazy is offline Novice
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    7
    I need to be able to export all the data to excel as well as create reports.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,965
    Cannot have subtotal rows in a normal SELECT query. If you want to display detail records as well as summary data, build report using Grouping & Sorting with aggregate calcs in group footer.

    A report can be exported to spreadsheet but often the results are not nice. Why Excel, why not a PDF?

    Or a lot of VBA to write records to a 'temp' table.
    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.

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You could likely do something with a union query but as we've said, trying to subtotal in a query is not really the best idea. Creating a report and exporting the report to excel would probably be your best (I've never done this)

    I'm enclosing a copy of your database doing subtotals with union queries, but again it's a very cumbersome thing to handle.

    Students.zip

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

Similar Threads

  1. Recall previous values on a form
    By Thermalmonster in forum Programming
    Replies: 12
    Last Post: 07-28-2014, 01:54 PM
  2. Replies: 8
    Last Post: 07-06-2013, 05:13 PM
  3. Replies: 6
    Last Post: 05-12-2012, 03:13 AM
  4. Replies: 1
    Last Post: 04-09-2012, 02:14 PM
  5. Replies: 1
    Last Post: 03-27-2010, 06:13 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