This SQL statement works perfectly when I run alone, it requests the input parameter. I want to pass the value in as the value on the form... but when I run it from an after insert event.... telling it to use [Forms]![StudentCourses]![CourseNo] in where statement... it doesnt work.
The statement won't run at all ... please can you help....
Private Sub Form_AfterInsert()
CurrentDb.Execute "INSERT INTO StudentComponents ( ComponentID, courseNo, rectype, StudentID, StuCourseID )" & _
" SELECT Components.ComponentID, Courses.courseNo, 'C' AS rectype, StudentCourses.StudentID, StudentCourses.StuCourseID" & _
" FROM (Coursetypes INNER JOIN (Components INNER JOIN Coursecomponents ON Components.ComponentID = Coursecomponents.ComponentID) ON Coursetypes.courseID = Coursecomponents.CourseID) INNER JOIN (Courses INNER JOIN StudentCourses ON Courses.courseNo = StudentCourses.CourseNo) ON Coursetypes.courseID = Courses.courseID" & _
" WHERE (((Courses.courseNo)=[Forms]![StudentCourses]![CourseNo]));"
End Sub