Results 1 to 5 of 5
  1. #1
    clzhou is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    4

    Help database setup please!

    Hi all,

    I'm a new user to MS Access and I'm trying to create a database to record the grades of students in different subjects.

    The final product I'd like to have is a form that displays a particular student's grades in every subject.

    I have created 3 tables: tblStudent, tblSubjects, tblGrades
    The relationships have been shown as attached picture. tblGrades acts as a link between student and subjects.

    I've also attached a screenshot of an example of tblStudents, with data entered for each of the 5 subjects.

    My questions:

    1. When adding a new student, is there a way to automatically populate all subjects to him/her? ie. instead of me typing the subject IDs, all existing IDs would populate to the new student

    2. If a new subject is added, how do I copy it to each and every student?



    3. In the form view (please see attached), how do I create a subtotal field that calculates the total score for the student for the particular filter showing? (eg. total for science subjects, total for humanities, etc)

    Thanks heaps in advance!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    1 and 2 require VBA code.

    3. Can't do subtotals. Can do a total for each column. Assuming this form is in Datasheet view, place cursor in in any row of the form, click the Totals button (looks like sigma) on the Home tab of ribbon. Under each column select the calc function. Build a report to show subtotals on groups.
    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
    clzhou is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    4
    thanks for the reply June7.
    I suspected that VBA might be required, but I can't really do much more than open queries/forms with VBA codes. Would you point me in a direction as to what codes?

    Would Append Queries work? I've tried it but always get the error message: MS Access cannot convert the data type.

    Quote Originally Posted by June7 View Post
    1 and 2 require VBA code.

    3. Can't do subtotals. Can do a total for each column. Assuming this form is in Datasheet view, place cursor in in any row of the form, click the Totals button (looks like sigma) on the Home tab of ribbon. Under each column select the calc function. Build a report to show subtotals on groups.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Simple VBA to add new record would be like:
    DoCmd.SetWarnings False
    DoCmd.RunSQL "INSERT INTO tablename (StudentID, Subject) VALUES(" & Me.studentID & ", 'Algebra')"
    DoCmd.SetWarnings True

    In your case this gets more complicated because of the multiple subjects. Because there are only 5, not hundreds, have a RunSQL for each of the subjects. The real trick is figuring out what event to put the code in - maybe a button Click.

    Copying records for a new subject to each student is even more complicated. One way is to open in VBA a recordset of students, in a loop, read each record to get student ID and execute RunSQL. Or might be possible by a single SQL statement with nested query and the looping of recordset would not be needed.

    Apostrophe delimiters are needed for text values, if date use #, nothing for numbers.

    An Append query to add subtotal lines into table? No, do NOT EVER do this. Build a report.
    Last edited by June7; 07-09-2011 at 12:35 AM.
    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
    clzhou is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    4
    Thanks for the reply June. I've worked out how to do this without VBA. It's a combination of Make-Table query and Append Query.

    1. Use Make table query to merge tblStudents and tblSubjects into tblJoint. This will create every combination of student and subjects
    2. Use Append query to add the new combinations into the existing table tblGrades

    I can present the data in a Form with subform, with a button click to run the queries and simple VBA command to turn off the warnings.

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

Similar Threads

  1. RE: Web database setup
    By abarin in forum Database Design
    Replies: 2
    Last Post: 05-31-2011, 05:47 PM
  2. Best way to setup
    By griz47 in forum Access
    Replies: 5
    Last Post: 05-17-2011, 12:59 AM
  3. Setup
    By aisza in forum Database Design
    Replies: 6
    Last Post: 05-09-2011, 03:43 PM
  4. Need help with database setup
    By ctyler in forum Database Design
    Replies: 6
    Last Post: 08-30-2010, 01:35 PM
  5. Please help with table setup
    By newhelpplease in forum Access
    Replies: 0
    Last Post: 10-14-2007, 01:15 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