I’m not an SQL Expert. Maybe what I’m trying to do here isn’t even possible.
I’m trying to get an updateable recordset that includes a field that is the result of an aggregate function.
I’m looking for something like this:
SELECT Contact.*, Count(OrderID) as CountOfOrders
FROM Contact INNER JOIN Order ON Order.ContactID = Contact.ContactID
WHERE ContactID = 1
When using the MSDataShape OLE DE provider and the OLE DB provider for Jet (or ACE) then it is indeed possible to create an updateable ADO recordset and
APPENDa computed column based on a set function such asCOUNT(). The resulting SQL-esque code would look more like this:Here’s a brief ‘proof of concept’: paste the following into any VBA module (e.g. use Excel), no references required, creates a new .mdb in your temp directory, creates the tables with data, to prove the recordset is updateable the
ContactNamevalue is changed and the recordset reopened to show it has indeed changed: