tech on the net
Home About Us Feedback Site Map

Microsoft

Access Excel Word

Database

SQL Oracle / PLSQL SQL Server MySQL MariaDB PostgreSQL

Web Development

HTML CSS Color Picker

Language

C Language

More

ASCII Table Linux UNIX Java Clipart Joke of the Moment

Other Sites

CheckYourMath BigActivities DigMinecraft
Share this page:

MS Access: DCount Function

Learn how to use the Access DCount function with syntax and examples.

Description

The Microsoft Access DCount function returns the number of records from an Access table (or domain).

Syntax

The syntax for the Microsoft Access DCount function is:

DCount ( expression, domain, [criteria] )

Parameters or Arguments

expression is the field that you use to count the number of records.

domain is the set of records. This can be a table or a query name.

criteria is optional. It is the WHERE clause to apply to the domain.

Applies To

The DCount function can be used in the following versions of Microsoft Access:

Example

Let's look at a simple example:

DCount("UnitPrice", "Order Details", "OrderID = 10248")

In this example, you would return the number of records in the Order Details table where the OrderID is 10248. This is the same as the following SQL statement:

SELECT Count([Order Details].UnitPrice) AS CountOfUnitPrice
FROM [Order Details]
WHERE ((([Order Details].OrderID)=10248));

Example (in VBA Code)

The DCount function can be used in VBA code in Microsoft Access. For example:

Dim LTotal As Long

LTotal = DCount("UnitPrice", "Order Details", "OrderID = 10248")

In this example, the variable called LTotal would now contain the number of records in the Order Details table where the OrderID is 10248.

Example (in SQL/Queries)

You can also use the DCount function in a query in Microsoft Access.

Microsoft Access