A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old April 9th, 2010, 07:22 AM posted to microsoft.public.access.tablesdbdesign
Jareddxp
external usenet poster
 
Posts: 2
Default How can I use relationships to auto-create records in my subform?

### 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

Ads
  #2  
Old April 9th, 2010, 09:05 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default How can I use relationships to auto-create records in my subform?

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" [email protected] wrote in message news:[email protected]
### 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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:47 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 OfficeFrustration.
The comments are property of their posters.