Results 1 to 9 of 9
  1. #1
    iheft is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2017
    Posts
    5

    Question Store a count as a field and then calculate a value?

    Hello,



    Thank you for taking the time to look at my question. This is a somewhat involved situation.

    I work in a department that manages practicum placements, and I was asked to keep track of the students who have been deferring placement for a variety of reasons. This has been a complicated process and I taught myself Access and, incrementally, using trial and error and YouTube and Google: I’ve made a behemoth of a database that is functional and robust and I keep adding new features such as determining when their 5-year expiry will be up and file closures and tracking statistics and reports, and contact with the students.
    Basically, I have a table to keep track of our students, and a table to keep track of deferrals. Each time a student submits a deferral form, I record their reason to defer (i.e. can’t find a placement, personal reasons, health, employment, etc) and date information.

    The issue is that sometimes, students do not submit deferral forms. So, we have to calculate how long they have been deferred based on the number of terms that have elapsed since they became eligible for placement.

    Therefore, say a student has been deferring every term since Winter of 2016. There are 3 practicum starts per year therefore, as of the current term, Spring 2017, they have deferred 5 times. Maybe we only have 3 forms for this person. That means there are 2 “Additional Deferrals” and 3 forms in the system for this person, and their Total Deferrals would be 5.
    SO – when I go to the form where I look up student information, I have a sub-form/query that counts the number of records in the database with the student number of the student currently displaying. Then there is a spot to enter “Additional Deferrals” and then under OnUpdate, when I type in a number, it calculates the total deferral and saves it under “TotalDef” in the Students database.
    My issue arises when I want to see how long students have deferred and this info doesn’t update on its own. I have to enter a number into Total Deferrals for each student, even if it’s 0 (i.e. maybe they’ve submitted their first form and there are no additional ones) for it to properly calculate.

    What I would like to do is:

    Do a count of how many deferrals are in the Deferral Table for each student number, and store this as a NumDef field in the Students table, so that I can calculate total deferrals. I have already managed to run this query, I set up the table/field relationships and did this query:

    SELECT Students.StudentID, Count(Deferrals.StudentID) AS NumDef
    FROM Students INNER JOIN Deferrals ON Students.StudentID = Deferrals.StudentID
    GROUP BY Students.StudentID;

    I get the number in the system from each student number in StudentID (and there are no duplicates), but I want to store the NumDef in the student table for the record that matches that StudentID. Append Query doesn’t work.

    I also tried to do a Lookup, but this just makes a drop-down box for a field in a table.

    Basically, I want to COUNT how many times each student number in the Students table matches the StudentID on a deferral in the deferral database, store that number in a field and then add it to the number of additional deferrals. And, now, since we are adding every deferral form as it comes in, there wouldn’t be that many additional deferrals, just once each term we’d add one to each person who hadn’t submitted a deferral yet.

    Does this make sense? Is there an easy way to do this?

    Thanks for your help!
    Ian

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Can you post your db, with a sample of data and just this part of the system? It would be easier to understand what you are trying to accomplish.

  3. #3
    iheft is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2017
    Posts
    5
    Quote Originally Posted by aytee111 View Post
    Can you post your db, with a sample of data and just this part of the system? It would be easier to understand what you are trying to accomplish.
    Thanks for offering to take a look at it. Unfortunately, I've got it split so there's a front end and a backend and I tried to copy it and change the linked tables and I haven't had any luck.

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Create a new db and import the form and tables that apply to this post.

  5. #5
    iheft is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2017
    Posts
    5
    OK so I was able to strip everything down to the bare bones of what I need - however, I couldn't attach it for some reason so it's available here https://www.dropbox.com/s/2pmb7iqfp9...se1.accdb?dl=0

    The NumDef1 query is for the subform on the Student Lookup form, the other one is the one that pulls the count from the deferral database, ideally, this is the number I'd want in the Student Table under "NumDef" (whether it comes from the query or is calculated as a count in the field or an append query or whatever would be the best way to do it.

    Thanks!
    Ian

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Learn to attach things to your posts, not everyone is able to access websites while at work. Click on "Go Advanced", find the paperclip/attach, browse to the file, click Upload.

    I gave you a whole new set of tables. Do yourself a favor and read up about database normalization. With this new structure you can do calculations far easier. NOTE: do not store calculated fields on tables - never!

    I don't think I have covered all your issues. Take a look and see if this will work for you.
    Attached Files Attached Files

  7. #7
    iheft is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2017
    Posts
    5
    I tried to attach it several times and kept getting an error, so it wasn't for lack of knowing how.

    Thanks for this, I will take a look. The actual database is bigger, more bloated and convoluted because it was my first attempt and because lots has been tacked on since but my next endeavor will be to streamline it and clean it up and make it make sense.

    Thanks for your time and help! Have a great evening
    Ian

    Quote Originally Posted by aytee111 View Post
    Learn to attach things to your posts, not everyone is able to access websites while at work. Click on "Go Advanced", find the paperclip/attach, browse to the file, click Upload.

    I gave you a whole new set of tables. Do yourself a favor and read up about database normalization. With this new structure you can do calculations far easier. NOTE: do not store calculated fields on tables - never!

    I don't think I have covered all your issues. Take a look and see if this will work for you.

  8. #8
    iheft is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2017
    Posts
    5
    Hi aytee111,

    Thanks for the idea of numbering the terms, I will look more into that being a possibility, because for example 2016 W(inter) comes before 2016 S(pring) but because of the alphabetical order they always show up out of order!

    However, I'm still wondering what would be the best way to store the number of deferrals in the system in the database? I can understand not keeping a calculation of total deferrals as you've said, but still is there a way to keep track of how many deferrals we have from this person stored in the db or would that need to be a query?

    Thanks
    Ian

  9. #9
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Did you look at the forms I created? The calcs are there, and can also be done in standard queries which you can then use whenever you need the values. These are not values that you keep track of, they are displayed as "now" values only, in 5 minutes they will change! Hence never storing calculated values.

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

Similar Threads

  1. Create a Field to Calculate Unique/Distinct Count
    By MikeNewAccessUser in forum Queries
    Replies: 3
    Last Post: 03-06-2015, 08:39 AM
  2. Store Modification History and Another Field
    By nygiantsfan in forum Access
    Replies: 2
    Last Post: 06-19-2014, 07:52 AM
  3. Replies: 9
    Last Post: 04-01-2014, 05:06 PM
  4. VB to calculate count of distinct values
    By gokul1242 in forum Programming
    Replies: 1
    Last Post: 10-03-2012, 01:38 PM
  5. Replies: 0
    Last Post: 09-25-2006, 03:42 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