How can I use relationships to auto-create records in my subform?

J

Jareddxp

### How can I use relationships to auto-create records in my subform? ###
Please Help!

Using Access 2007, I am trying to create a "Classroom Database" where I can
manage students and grades (for one class). I have created the following

tbl.Student
-SID (auto)
-LastName
-FirstName-
-StudentID
-Comments

tbl.Assignments
-AID (auto)
-Date
-Assignment
-Notes

tbl.Grades
-RID
-Student (looks up student ID)
-Assignment (looks up assignment)
-Grade (%)
-Note

Thus far, I have created two forms (each with a subform), one which allows me
to open up an assignment and see grades by student, and another where I can
view all of a students grade.

### My question, and I have seen this before, is that I would like ALL of the
students to be added to each assignment automatically. As it is now, I need
to add a new record for each student under each assignment (grab their name
from the dropdown list). How can I setup the subforms to automatically
propogate a GRADE record with each student name and a blank Grade field? ###

Thank You! Jared
 
A

Allen Browne

Execute an Append query statement.

Choose when you want to do this. I assume that tblGrades.Assignment is a
Number field that matches tblAssignments.AID. To get the select statement:
1. Create a new query.

2. Change it to an Append Query (Append on Query menu)
Tell it you want to append to tblGrades.

3. Type an expression into a fresh row like this:
SID:99

4. Output the AID field, and indicate it goes to the Assignment field.

5. Switch the query to SQL View (View menu.)
There's a sample statement to use.

In your VBA code, you need to generate a string just like that, but
concatenate the actual StudentID value into the string in place of the 99.

You can then Execute this statement in the appropriate event procedure (e.g.
in the AfterInsert event procedure of the form where you enter new
students.)

If Execute is new, see this example:
http://allenbrowne.com/ser-60.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top