Apart from the slightly different order of field specifications, can some kind individual tell me what the difference is between these two SQL statements?
STATEMENT 1
SELECT GESTUCENTRES.SetId, GESTUCENTRES.StudentId, GESTUCENTRES.CandId, GESTUCENTRES.CentreId, GESTUCENTRES.CandNumber, GESTUCENTRES.CandStatus, GESTUCENTRES.CandQualifier, GESTUCENTRES.SecCentreId, GESTUCENTRES.SecCandNumber, GESTUCENTRES.DocGroup, GESTUCENTRES.CChanged, GESTUCENTRES.CReturned, GESTUCENTRES.CEmptyReturn, GESTUCENTRES.CFlaggedDelete FROM GESTUCENTRES WHERE (((GESTUCENTRES.CandNumber) In (SELECT [CandNumber] FROM [GESTUCENTRES] As Tmp GROUP BY [CandNumber] HAVING Count(*)>1 ))) ORDER BY GESTUCENTRES.CandNumber;
STATEMENT 2
SELECT GESTUCENTRES.CandNumber, GESTUCENTRES.SetId, GESTUCENTRES.StudentId, GESTUCENTRES.CandId, GESTUCENTRES.CentreId, GESTUCENTRES.CandStatus, GESTUCENTRES.CandQualifier, GESTUCENTRES.SecCentreId, GESTUCENTRES.SecCandNumber, GESTUCENTRES.DocGroup, GESTUCENTRES.CChanged, GESTUCENTRES.CReturned, GESTUCENTRES.CEmptyReturn, GESTUCENTRES.CFlaggedDelete FROM GESTUCENTRES WHERE (((GESTUCENTRES.CandNumber) In (SELECT [CandNumber] FROM [GESTUCENTRES] As Tmp GROUP BY [CandNumber] HAVING Count(*)>1 ))) ORDER BY GESTUCENTRES.CandNumber;
Statement 2 was generated using a query generated by the query wizard for finding duplicate records and works.
Statement 1 was generated in VBA from tables and fields selected by the user using combo boxes on a form. When the code is run it gets as far as the VBA instruction
DoCmd RunSQL SQL
where SQL = Statement 1, but falls over with Run-time error 2342 "A RunSQL action requires an argument consisting of an SQL statement".
Any ideas, please, would be much appreciated.
John R
STATEMENT 1
SELECT GESTUCENTRES.SetId, GESTUCENTRES.StudentId, GESTUCENTRES.CandId, GESTUCENTRES.CentreId, GESTUCENTRES.CandNumber, GESTUCENTRES.CandStatus, GESTUCENTRES.CandQualifier, GESTUCENTRES.SecCentreId, GESTUCENTRES.SecCandNumber, GESTUCENTRES.DocGroup, GESTUCENTRES.CChanged, GESTUCENTRES.CReturned, GESTUCENTRES.CEmptyReturn, GESTUCENTRES.CFlaggedDelete FROM GESTUCENTRES WHERE (((GESTUCENTRES.CandNumber) In (SELECT [CandNumber] FROM [GESTUCENTRES] As Tmp GROUP BY [CandNumber] HAVING Count(*)>1 ))) ORDER BY GESTUCENTRES.CandNumber;
STATEMENT 2
SELECT GESTUCENTRES.CandNumber, GESTUCENTRES.SetId, GESTUCENTRES.StudentId, GESTUCENTRES.CandId, GESTUCENTRES.CentreId, GESTUCENTRES.CandStatus, GESTUCENTRES.CandQualifier, GESTUCENTRES.SecCentreId, GESTUCENTRES.SecCandNumber, GESTUCENTRES.DocGroup, GESTUCENTRES.CChanged, GESTUCENTRES.CReturned, GESTUCENTRES.CEmptyReturn, GESTUCENTRES.CFlaggedDelete FROM GESTUCENTRES WHERE (((GESTUCENTRES.CandNumber) In (SELECT [CandNumber] FROM [GESTUCENTRES] As Tmp GROUP BY [CandNumber] HAVING Count(*)>1 ))) ORDER BY GESTUCENTRES.CandNumber;
Statement 2 was generated using a query generated by the query wizard for finding duplicate records and works.
Statement 1 was generated in VBA from tables and fields selected by the user using combo boxes on a form. When the code is run it gets as far as the VBA instruction
DoCmd RunSQL SQL
where SQL = Statement 1, but falls over with Run-time error 2342 "A RunSQL action requires an argument consisting of an SQL statement".
Any ideas, please, would be much appreciated.
John R