Question : Groupby in a recordset in a Access VBA code module.

How do I do a Groupby in a recordset in a Access VBA code module.
Thanks.

Answer : Groupby in a recordset in a Access VBA code module.

You construct a SQL string with the SELECT and GROUP BY clauses, and use that with OpenRecordset.

For example:

Dim rs as DAO.Recordset
Dim sSQL as string
sSQL = "SELECT City, Count(CustomerID) as CustCount FROM Customers GROUP BY City;"
Set rs CurrentDb.OpenRecordset( sSQL )

--
Graham

Random Solutions  
 
programming4us programming4us