Hi
I am new to Queries. This simple database is about the recording of Student Patient vaccinations in school.
I have an intermediate table called intbl_School_Patient which links to tbl_Patient and tbl_Schools.
In the intbl_School_Patient table I have a field for Since_Date which is the date the student/patient started at that school.
When I am in the form frm_Students, I click on a button that opens a form where I can add a new school that the student/patient is now attending. When I close that form, I want to pull just the Name of the School that has the latest date against it for that Student/Patient and add it to a text box (actually a label) on my form. I have created a query but it is pulling back all the schools and dates for some reason.
Code:
SELECT tbl_Schools.School_Name, intbl_School_Patient.Since_Date
FROM tbl_Schools INNER JOIN intbl_School_Patient ON tbl_Schools.School_ID = intbl_School_Patient.School_ID
GROUP BY tbl_Schools.School_Name, intbl_School_Patient.Since_Date, intbl_School_Patient.School_Patient_ID, intbl_School_Patient.School_ID, intbl_School_Patient.Patient_ID
HAVING (((intbl_School_Patient.Patient_ID)=[Forms]![frm_Patient2]![txt_Patient_ID]))
ORDER BY intbl_School_Patient.Since_Date DESC;
Any help would be appreciated