Access 2007-2019 Access 2000-2003 Access Seminars TechHelp Support Tips & Tricks Access Forum Course Index Topic Glossary Insider Circle

 Home   News   Courses   Seminars   Templates   Help   TechHelp   Forums   Order   Contact   Logon More... What's New? Tips & Tricks Access Index Access Tips Excel Index Excel Tips Waiting List

 Access    Excel    Word    Windows    HTML

# DCount

## Using the DCOUNT Function

In this tutorial you will learn how to use the DCOUNT Function.

Take an example Table of Customers.

CustomerT
CustomerIDFirstNameLastNamePhoneCustomerSinceCreditLimitDaysGraceIsActive
1RichardRost716555777701/01/201210011True
2JoeSmith716555343401/03/19905005True
3SuzanJones562436514602/01/199815002False
4AlanWatson419389121217/05/2012503True
5AnnaPicore71323647905/05/200510204True
6RonaldSimms780746546804/04/1992502True
7DonaldBarker416441555501/03/19982505True
8BennySperduti716726726206/04/199916007False
9PeteSmith564559777704/04/20005003False
10BarbraPeters829282728831/12/2005501True
11JoeJones549546546601/06/20045003True
14PezzDispo26/09/201204True
16BobSmith04/10/201209True

In this example we want to find out how many Customers have a Credit Limit equal to 50 so we set the Field to * to choose any/all Fields in the Table, the Domain is CustomerT as this is the Table we are searching and the Criteria of "CreditLimit=50" as this is the Field name we are searching on.

The DCOUNT function returns an integer from a specified set of records (or domain) containing the number of records in that search.

=DCOUNT(Field, Domain, Criteria)

Query

The results using a Query would be

```	SELECT * FROM CustomerT WHERE CreditLimit = 50
```
tblNames
CustomerIDFirstNameLastNamePhoneCustomerSinceCreditLimitDaysGraceIsActive
4AlanWatson419389121217/05/2012503True
6RonaldSimms780746546804/04/1992502True
10BarbraPeters829282728831/12/2005501True

FORM

In a Form you could set the Default Value of a Textbox to

```	=DCount("*", "CustomerT", "CreditLimit=50")
```
VBA

In a Form add a TEXTBOX control and rename it "txtDCount", then you could add the following in the Load Event.

```	Private Sub Form_Load()
txtDCount = DCount("*", "CustomerT", "CreditLimit=50")
End Sub
```

Tips

See this FREE Tip on DCOUNT.

Search