DanGriffin
Programmer
I copied and pasted this sql statement from the design view of an Access query into the code for a report. In the report I get a sintax error on the FROM clause??
This the qry statement from the datasheet query:
SELECT A.Code, A.Title, A.Wage, A.Year
FROM Positions AS A INNER JOIN [SELECT Code, Max([Year]) AS MaxYear FROM Positions GROUP BY Code
]. AS B ON (A.Year = B.MaxYear) AND (A.Code = B.Code)
ORDER BY A.Code;
and this is the report code that triggers an error:
Option Compare Database
Option Explicit
Private Sub Report_Open(Cancel As Integer)
Dim dbs As Database, rstHours As Recordset, rstReport As Recordset, rstPos As Recordset
Set dbs = CurrentDb()
Set rstPos = dbs.OpenRecordset("SELECT A.Code, A.Title, A.Wage, A.Year FROM Positions AS A INNER JOIN [SELECT Code, Max([Year]) AS MaxYear FROM Positions GROUP BY Code]. AS B ON (A.Year = B.MaxYear) AND (A.Code = B.Code) ORDER BY A.Code;")
It's copy-n-paste! How could there be an error??
This the qry statement from the datasheet query:
SELECT A.Code, A.Title, A.Wage, A.Year
FROM Positions AS A INNER JOIN [SELECT Code, Max([Year]) AS MaxYear FROM Positions GROUP BY Code
]. AS B ON (A.Year = B.MaxYear) AND (A.Code = B.Code)
ORDER BY A.Code;
and this is the report code that triggers an error:
Option Compare Database
Option Explicit
Private Sub Report_Open(Cancel As Integer)
Dim dbs As Database, rstHours As Recordset, rstReport As Recordset, rstPos As Recordset
Set dbs = CurrentDb()
Set rstPos = dbs.OpenRecordset("SELECT A.Code, A.Title, A.Wage, A.Year FROM Positions AS A INNER JOIN [SELECT Code, Max([Year]) AS MaxYear FROM Positions GROUP BY Code]. AS B ON (A.Year = B.MaxYear) AND (A.Code = B.Code) ORDER BY A.Code;")
It's copy-n-paste! How could there be an error??