So I am doing a project where we are attempting to allow our user to open the form, select (via a combobox) an instructor, and then return all the students who have had that instructor over the years in a table.
Without the WHERE clause the code runs, returning all the students who have had that instructor. But when I use the [Forms]![STUDENT FORM]![INSTRUCTOR] in the WHERE clause we suddenly get no results. Can anyone explain why this is? It has worked in the same form with a different combobox, but we didn't need to use any joins, so I'm wondering if that's the issue?
This is the SQL code - our form is named STUDENT FORM and the combobox is named INSTRUCTOR:
SELECT STUDENT.STU_LNAME, STUDENT.STU_FNAME, STUDENT.[STU_ INT],
STUDENT.STU_NICK, STUDENT.STU_YEAR, STUDENT.STU_PHONE, STUDENT.STU_EMAIL,
INSTRUCTOR.INSTRUCTOR_LNAME FROM
(INSTRUCTOR INNER JOIN CLASS ON
INSTRUCTOR.[INSTRUCTOR_ID] = CLASS.[INSTRUCTOR_ID]) INNER JOIN
(STUDENT INNER JOIN ENROLL ON STUDENT.[STU_NUM] = ENROLL.[STU_NUM])
ON CLASS.[CLASS_ID] = ENROLL.[CLASS_ID]
WHERE (((INSTRUCTOR.INSTRUCTOR_LNAME)=[Forms]![STUDENT FORM]![INSTRUCTOR]));
Please let me know if you need any more information!