Hi
I currently have 2 queries..
Query 1 select statement getting count of field
Query 2 getting max of Query 1
Instead of the queries I want to do this in vba with a recordset
The slq works fine for the first Query, I could then do a iMax = rs("CountOfROUTE") to get the max value as they are ordered.
but how can I write sql 2 so that it selects the Max from the Query 1 select statement.
Hope this makes sens
I currently have 2 queries..
Query 1 select statement getting count of field
Query 2 getting max of Query 1
Instead of the queries I want to do this in vba with a recordset
Code:
' Select from first query
sql = "SELECT tblOriginal.ROUTE, Count(tblOriginal.ROUTE) AS CountOfROUTE " & _
"FROM tblOriginal " & _
"GROUP BY tblOriginal.ROUTE " & _
"ORDER BY Count(tblOriginal.ROUTE) DESC"
' Select max from result of first query
sql2 = "SELECT Max(qryRouteCount.CountOfROUTE) AS MaxOfCountOfROUTE " & _
"FROM qryRouteCount;"
The slq works fine for the first Query, I could then do a iMax = rs("CountOfROUTE") to get the max value as they are ordered.
but how can I write sql 2 so that it selects the Max from the Query 1 select statement.
Hope this makes sens