I put the DMAX in a query , then used ADO to get the query and it worked.
NOT the command you used...the sql version. (yours above is an Access command)
It might be best if you explain what is being done - inputs & outputs - to help understand what approach to use.
"SELECT ReadingDate, Field1, Field2, Field3, " _
& "Field4, Field5, Field6, Field7, " _
& "Field8, Field9, Field10, Field11, " _
& "Field12, Field13, Field14, " _
& "Field15, Prop_KEY, IIf([Prop_KEY]=[WH_IDX],IIf(DMax('Field9','tblDailyReadings','Prop_KEY=" & Prop_KEY & "')<1,1,DMax('Field9','tblDailyReadings','Prop_KEY=" & Prop_KEY & "'))) AS MaxValComment " _
& "FROM tblComments RIGHT JOIN tblDailyReadings ON tblComments.CommentDate = tblDailyReadings.ReadingDate " _
& "WHERE (((tblDailyReadings.Prop_KEY)=" & Prop_KEY & ")) " _
& "GROUP BY ReadingDate, Field1, Field2, Field3, " _
& "Field4, Field5, Field6, Field7, " _
& "Field8, Field9, Field10, Field11, " _
& "Field12, Field13, Field14, " _
& "Field15, Prop_KEY, IIf([Prop_KEY]=[WH_IDX],IIf(DMax('Field9','tblDailyReadings','Prop_KEY=" & Prop_KEY & "')<1,1,DMax('Field9','tblDailyReadings','Prop_KEY=" & Prop_KEY & "')));"
Debug.Print Join$(Array( _
"SELECT C.ReadingDate, C.Field1, C.Field2, C.Field3, C.Field4, C.Field5, C.Field6, C.Field7, C.Field8, C.Field10, C.Field11, C.Field12, C.Field13, C.Field14, C.Field15, C.Prop_KEY, MIN(1,MAX(C.Field9)) AS [MaxValComment]", _
"FROM tblComments C RIGHT JOIN tblDailyReadings R ON C.CommentDate = R.ReadingDate", _
"WHERE R.Prop_KEY=" & Prop_KEY, _
"GROUP BY C.ReadingDate, C.Field1, C.Field2, C.Field3, C.Field4, C.Field5, C.Field6, C.Field7, C.Field8, C.Field10, C.Field11, C.Field12, C.Field13, C.Field14, C.Field15, C.Prop_KEY"), vbCr)
Below is the best I can do for now. Please give sample inputs & outputs - to help understand what approach to use. My current understanding is not clear.
I assume this is a query that is run once only: not modified slightly and run repeatedly which I think would be wrong - if that were the case another table would be included in the SQL. Prop_KEY is understood to be numeric, not text.
Code:Debug.Print Join$(Array( _ "SELECT C.ReadingDate, C.Field1, C.Field2, C.Field3, C.Field4, C.Field5, C.Field6, C.Field7, C.Field8, C.Field10, C.Field11, C.Field12, C.Field13, C.Field14, C.Field15, C.Prop_KEY, MIN(1,MAX(C.Field9)) AS [MaxValComment]", _ "FROM tblComments C RIGHT JOIN tblDailyReadings R ON C.CommentDate = R.ReadingDate", _ "WHERE R.Prop_KEY=" & Prop_KEY, _ "GROUP BY C.ReadingDate, C.Field1, C.Field2, C.Field3, C.Field4, C.Field5, C.Field6, C.Field7, C.Field8, C.Field10, C.Field11, C.Field12, C.Field13, C.Field14, C.Field15, C.Prop_KEY"), vbCr)