Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

Domain Aggregate Functions

From Wiki

Jump to: navigation, search

The domain aggregate functions are as follows.

Commonly used:

  • DAvg
  • DCount
  • DLookup
  • DMin, DMax
  • DSum

Less Commonly Used:

  • DFirst, DLast
  • DStDev, DStDevP
  • DVar, DVarP

Using DCount as an example, the way they work is:

DCount("[SomeField]","tblMembers","[SomeField]=1")

There is an Or for the WHERE statement, and that is, if the comparison is a variable, you put it outside the quotes. Then it gets a little more complicated, if the comparison is to a text field, you need single quotes (''), if it is a date field, you need hash signs (##) and if it is to a number, you do not need anything. So:

A control on a form can be referenced as part of the WHERE statement, of course the form must be open:

   DLookup("Surname & ', ' & Forename", "tblMembers", "SomeField=Forms!Members!Somefield") 

You do not need delimiters when referring to a control in this way. Note that the example above will return both surname and forename. The first and last arguments (what to look up, and WHERE statement) can be a number of different expressions and can include a number of fields, pretty nearly anything you would use in a similar query will work, for example:

   DAvg("[HrlyRate]*80","tblWages","Gender='F' AND Status='A' AND HireDate>=#" & dteD & "#")

Functions can also be combined:

   DLookup("code", "tblmembers", "CrDate=DMax('CrDate','tblMembers')")

Further Information

Domain Aggregate Functions: http://msdn2.microsoft.com/en-us/library/aa212172(office.11).aspx

List of reserved words in Access 2002 and in later versions of Access: http://support.microsoft.com/kb/286335

609 Rating: 1.0/5 (1 vote cast)