I seem to be getting a run of these at the moment – a query string that runs if I paste it into a query object, but that gives an arror when I use it to open a recordset.
The query string is:
SELECT Week_Start_Date, Week_End_Date, RWYear, AgrWeek FROM qry_RetailWeeks WHERE [RWDate] = #26 August 2004#
When I try to open an recordset it gives an ‘Error in FROM clause’ error. The recordset opening code is:
rst.Open strSQL, CurrentProject.Connection, , , adCmdTable
with the query string in strSQL. qry_RetailWeeks is a simple select statement that I used to change the names of two of the fields in the underlying table. I did this when I first got the error because I thought that the field names might be reserved words and therefore the cause the error. The SQL for sql_RetailWeeks:
SELECT RetailWeeks.Date AS RWDate, RetailWeeks.AgrWeek, RetailWeeks.Week_Start_Date, RetailWeeks.Week_End_Date, RetailWeeks.Year AS RWYear
FROM RetailWeeks;
Is there something obvious in my SQL or, is it possible that ADO doesn’t like reserved words as columns column names even when it is ‘once removed’ from the underlying table? RetailWeeks is a table used everywhere by the client and cannot be changed.
Thanks again
Ian