This is more of a SQL/asp question as that is where I am getting the problem but I thought Access people would know what’s going on here.
I am trying to pull some results from Access to a webpage via asp and thought it would be nice to use the Group By function to create blocks of data in a way similar to an Access report. If I run something like this:
strSQL = “SELECT Categories, CRCGType, MemberType, FullName FROM tblOutlookContacts Group BY Categories, CRCGType, MemberType”
I get this error:
Microsoft JET Database Engine error ‘80040e21’
You tried to execute a query that does not include the specified expression ‘FullName’ as part of an aggregate function.
I looked up a trouble-shooting website and got this advice:
If you are using an aggregate function (e.g. SUM, COUNT, MAX), then any other column in the SELECT list must also be in the GROUP BY clause. This is so that the database knows how to organize results.
Which makes NO SENSE to me because it seems perfectly logical to want to group a recordset by a some criteria but not ever one of them! After all, in access’ reports, you can group by certain headers on a report and the ‘body’ information will show all the records that match the grouped criteria.
For example, I’m trying to group the recordset to show all the contact information available (for example, the first names, addresses, etc.) for each group category or, as another way of saying it, show all contact info where Categories, CRCGType and MemberType are the same. So why is SQL requiring that EVERY piece of data in the recordset be grouped?
I am boggled by this…