Article ID: 210150 - Last Review: October 11, 2006 - Revision: 2.2 ACC2000: How to Count Values in Record or Recordset Across FieldsThis article was previously published under Q210150 Advanced: Requires expert coding, interoperability, and multiuser skills.
On This PageSUMMARY
This article shows you how to create a sample user-defined Visual Basic for
Applications routine that you can use to count the occurrence of a specific field value in a record or recordset.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. MORE INFORMATION
The following function is designed for Text fields, but you can modify it
to work with any data type. It assumes that all fields are of the same data
type. This function is designed to work on a single table or query. It accepts the following two arguments:
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. ExamplesTo create the function, follow these steps:
If you want to search all fields in only one record, use the following sample code. This example searches all fields in the first record only.
| Article Translations
|
Back to the top
