Hello,
I am using following query to insert values in tblSubjectExam but with condition that if those values do not exist already. SQL is:
When I run the query, it create duplicate records. CboExamID is like First Term, Second Term and Final Term. The form frmSubjects contain combo boxes by which user select Class (ClassID) and Exam Term. Purpose is to create records in tblSubjectExam for specific class and all the subjects registered for that class when term is changed and if records for that are already not present. I have spent my whole day to figure out this but failed. Please help.
Best Regards
I am using following query to insert values in tblSubjectExam but with condition that if those values do not exist already. SQL is:
SQL:
INSERT INTO tblSubjectExam ( ClassSubjectID, ExamTerm )
SELECT DISTINCTROW tblClassAndSubjects.ClassSubjectID, [forms]![frmSubjects]![cboExamID] AS expExamTerm
FROM tblClassAndSubjects LEFT JOIN tblSubjectExam ON tblClassAndSubjects.ClassSubjectID = tblSubjectExam.ClassSubjectID
WHERE (((tblClassAndSubjects.ClassID)=[forms]![frmSubjects]![cboClassID]) AND ((tblSubjectExam.ExamTerm)<>[forms]![frmSubjects]![cboExamID]));
When I run the query, it create duplicate records. CboExamID is like First Term, Second Term and Final Term. The form frmSubjects contain combo boxes by which user select Class (ClassID) and Exam Term. Purpose is to create records in tblSubjectExam for specific class and all the subjects registered for that class when term is changed and if records for that are already not present. I have spent my whole day to figure out this but failed. Please help.
Best Regards