question regarding repetition

isapple

Registered User.
Local time
Yesterday, 20:05
Joined
Jun 24, 2014
Messages
15
Hi,

So I have a grade database, and I want to make sure I don't input the student's grade twice. I only input grades once a day, since there are a fixed amount of grades that a student will have everyday.

Each student has his ID, and each student has a day for whatever his grades entered. What I don't want is that for example, student id 1000 has grades on 10/10/10, but maybe I left and was entering grades and then Id have two 10/10/10 records for student number 1000.
Is there any validation rules I can set in place so that a field within a primary key does not repeat?

To be more clear,
student 1000 would have grades on 10/10/10 , and student 1001 would also have grades on 10/10/10 (so date cannot be primary key), but there can only be 1 instance of a date for each student.
 
Do you have Student, Subject tables (and perhaps more).
Seems there could be a tblStudentSubject with Fields
StudentId
SubjectId
Grade
GradeDate

Just thinking and writing.
 
Well one way would be to put some code in the Before Update event of the date field that would use DLookup() function with some criteria to find a record for that student and that date. If a record is found the Update can be cancelled and a message displayed to the user with an explanation.
 
I only input grades once a day, since there are a fixed amount of grades that a student will have everyday.
Seems there could be a tblStudentSubject with Fields
StudentId
SubjectId
Grade - linked to a Grades table
GradeDate
You'll definitely be needing a similar structure as jdraw described.

And you can do it as bob fitz describes or another way would be to have all four fields as composite keys, letting Access enforce integrity.
 

Users who are viewing this thread

Back
Top Bottom