Count the number of records in an underlying query (MDB)

Use the Count and DCount functions to count the number of records in a domain, such as a query. Use the Count function when writing SQL statements, and the DCount function when writing Visual Basic for Applications (VBA) code, macros, and expressions. Note that you can't use these functions in a data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.). Additionally, you can't use the DCount function in an Access project (.adp).

Expression Description
Count([OrderID]) Uses the Count function to display the number of records in the current query.
Count(*) Uses the Count function to count the number of records in the query, including records with Null (Null: A value you can enter in a field or use in expressions or queries to indicate missing or unknown data. In Visual Basic, the Null keyword indicates a Null value. Some fields, such as primary key fields, can't contain a Null value.) (blank) fields.
DCount("[ShippedDate]", "Orders", "[ShipCountry] = '" & strCountry & _ "' AND [ShippedDate] > #" & dteShipDate & "#") Returns the number of orders in the Orders table that were shipped to a specified country/region (strCountry) after a specified ship date (dteShipDate). The domain is the Orders table.
 
 
Applies to:
Access 2003