ACC2000: #Error with Aggregate Function on a Form Based on ADO Recordset (244146)
The information in this article applies to:
This article was previously published under Q244146 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
SYMPTOMS
When you use aggregate functions, such as Sum, Count, Min, and Max, you may receive a #Error error when the form is based on an ActiveX Data Object (ADO) recordset.
CAUSE
You cannot use aggregate functions on an ADO recordset in Microsoft Access.
RESOLUTION
Base the form on a Data Access Objects (DAO) recordset instead. For example, in the sample database Northwind.mdb, if you want to base the Products form on a recordset object and also want to use aggregate functions on the form, place code in the OnLoad event of the form that bases the form on a DAO recordset. NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.
The code would look like the following:
Private Sub Form_Load()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT * FROM Products")
Set Me.Recordset = rst
End Sub
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbnofix kbprb kbProgramming KB244146 |
---|
|