I am in the process of converting sql strings to incorporate "select distinct" and also to use currentdb.execute where appropriate.
As I understand it, "select distinct" eliminates the need for the "Group" clause.
The following code seem to refute that.
What am I doing wrong?
I understand the setwarnings is unnecessary, I'm yet to remove those.
	
	
	
		
removing the alias has no effect on the error.
 As I understand it, "select distinct" eliminates the need for the "Group" clause.
The following code seem to refute that.
What am I doing wrong?
I understand the setwarnings is unnecessary, I'm yet to remove those.
		Code:
	
	
	Public Sub getBaySheets()
    DoCmd.SetWarnings False
        DoCmd.RunSQL "DELETE * FROM Bay_Sheet"
        sqry = "INSERT INTO bay_sheet ( Family, Infra, Bay, Shelf, FirstBox, LastBox ) " & _
               "SELECT DISTINCT A.Family, A.Infra, A.Bay, A.Shelf, Min(A.Box) AS MinOfBox, Max(A.Box) AS MaxOfBox " & _
               "FROM Counted as A " & _
               "ORDER BY A.Family, A.Infra;"
        CurrentDb.Execute sqry, dbFailOnError
    DoCmd.SetWarnings True
End Sub
	removing the alias has no effect on the error.