This is the original query as written in SQL
-----------
SELECT qryStudents.*, sqlEvents.*
FROM qryStudents
LEFT JOIN (SELECT tblEvents.* FROM tblEvents WHERE
[EventDate] >= #25/02/2004#)
AS sqlEvents
ON qryStudents.StudentID = sqlEvents.StudentID
WHERE [OffRoll] = False
This is how Access rewrites it after saving the query
--------
SELECT qryStudents.*, sqlEvents.*
FROM qryStudents LEFT JOIN [SELECT tblEvents.* FROM
tblEvents WHERE [EventDate] >= #25/02/2004#]. AS
sqlEvents ON qryStudents.StudentID = sqlEvents.StudentID
WHERE [OffRoll] = False;
This is how Access rewrites it when I have directly
entered it as the record source for the report.
SELECT qryStudents.*, sqlEvents.* FROM qryStudents LEFT
JOIN [SELECT tblEvents].[* FROM tblEvents WHERE
[EventDate] >= #25/02/2004#] AS sqlEvents ON
[qryStudents].[StudentID]=sqlEvents.StudentID WHERE
[OffRoll]=False;
When I try and use this as the basis of a report it fails
to work producing the following message
"Syntax Error in From Clause"
If I modify the SQL that Access has written (e.g.
changing the date) the error message also appears.
The purpose of the report is to provide a count of
different types of event within a certain time scale
whilst including those students for whom there are no
events.
I know here are other ways of providing this data, one of
which I have used (Creating a union of all those students
with no events, with those with events and then filtering
to include Null dates as well as those meeting the
criteria.
It is more a request to see if anybody knows a way to
prevent Access modifying the SQL, rather than finding a
workaround
What I find really strange is that if I open the new SQL
statement as written by Access, which is producing the
correct result when viewing the query, copy the SQL
statement and then paste it directly back in, it doesn't
work!
-----Original Message-----
I have created a query in SQL that performs a left join
on a table of students and a select statement
The query works correctly when viewed on screen, but when
I try to use the query as the record source of a report,
it is rewritten by MS Access, and subseqentially doesn't
work.
Any ideas how to get round this one!
.