From: Jareddxp on
### 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

From: Allen Browne on
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Jareddxp" <u59235(a)uwe> wrote in message news:a64274c2a5305(a)uwe...
> ### 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
>
 | 
Pages: 1
Prev: Products/Services Table
Next: Linked servers