Desmond_Fox
Registered User.
- Local time
- Today, 14:55
- Joined
- Dec 3, 2014
- Messages
- 12
Hi,
I've spent many days trying to work this out. I don't even know if I can explain what I'm trying to do clearly, so here goes.
Any pointers in the right direction would be wonderful.
Here is the set up
The tables (simplified)
tbl_Students (has StudentID, StudentName)
tbl_SubjectList (has SubjectID, SubjectName)
tbl_Comments (has CommentID, SubjectID (foreign key), StudentID (foreign key), Comment)
The forms
The Master and Child (main form and subform) are linked using StudentID.
I use a query for fields in the Master form. Each subform has its own query that shows results for a particular subject.
The problem
My subform allows me to edit an existing comment fine (if I enter dummy data directly in a table).
BUT, if there isn't an existing comment, and I attempt to enter one, I get an error - "YOU CANNOT CHANGE A RECORD BECAUSE A RELATED RECORD IS REQUIRED IN TABLE tbl_Subjects."
What I have tried
I understand this error means I am violating referential integrity rules. But I can't see why. The tbl_Subjects is populated with 10 subjects and I am only trying to put a comment against an existing SubjectID.
I've checked that my Form Master / Subform Child is ok. I experimented with having StudentID _and_ Subject_ID to link the master and subform to see if that worked. It only made things worse because my subforms wouldn't display correctly.
Anyway, any tips or pointers in the right direction would really help.
Thanks
Des
I've spent many days trying to work this out. I don't even know if I can explain what I'm trying to do clearly, so here goes.
Any pointers in the right direction would be wonderful.
Here is the set up
- I have a primary school database.
- There is a main form that shows the students name and class.
- The main form contains tabs for each subject (maths, english etc.). Each tab has a subform that is supposed to allow me to enter a comment about the student's progress.
- My tables are set up properly (as far as I can tell).
The tables (simplified)
tbl_Students (has StudentID, StudentName)
tbl_SubjectList (has SubjectID, SubjectName)
tbl_Comments (has CommentID, SubjectID (foreign key), StudentID (foreign key), Comment)
The forms
The Master and Child (main form and subform) are linked using StudentID.
I use a query for fields in the Master form. Each subform has its own query that shows results for a particular subject.
The problem
My subform allows me to edit an existing comment fine (if I enter dummy data directly in a table).
BUT, if there isn't an existing comment, and I attempt to enter one, I get an error - "YOU CANNOT CHANGE A RECORD BECAUSE A RELATED RECORD IS REQUIRED IN TABLE tbl_Subjects."
What I have tried
I understand this error means I am violating referential integrity rules. But I can't see why. The tbl_Subjects is populated with 10 subjects and I am only trying to put a comment against an existing SubjectID.
I've checked that my Form Master / Subform Child is ok. I experimented with having StudentID _and_ Subject_ID to link the master and subform to see if that worked. It only made things worse because my subforms wouldn't display correctly.
Anyway, any tips or pointers in the right direction would really help.
Thanks
Des