Solved

DCount Syntax

Posted on 2014-02-26
4
325 Views
Last Modified: 2014-02-26
Hi,

Table is tblOrders
Field Name is CustomerNumber

I want to display the number of times a CUSTOMER has placed an order.

So, if I am looking at a form that displays a single order for CUSTOMER 888 - I want the form to display that this CUSTOMER has 999 Orders already.

Each time an order is displayed on the screen , then there should also be a display of the total number of orders placed by that customer.

What's the DCOUNT format??

Thanks!
0
Comment
Question by:Patrick O'Dea
  • 2
4 Comments
 
LVL 19

Assisted Solution

by:MINDSUPERB
MINDSUPERB earned 150 total points
ID: 39888381
Try this:

=DCount("[CustomerNumber]", "tblOrders", "[CustomerNumber] = 888")

Sincerely,

Ed
0
 
LVL 84
ID: 39888384
Without knowing your table structure it's hard to give exact syntax, but assuming you have an Orders table, with a field named Customer, then something like:

Nz(DCount("IDField", "Orders", "Customer=" & Me.Customer),0)

If "Customer" is a Text field:

Nz(DCount("IDField", "Orders", "Customer='" & Me.Customer & "'"),0)

This would tell you the number of orders EVER placed by the customer.

"IDFIeld" is any field in the table, although it's generally better to use an indexed field. If you have an Autonumber field in the table  use that.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 350 total points
ID: 39888386
Note that you'd want to do this on the Form's Current event, so something like this:

Sub Form_Current()
  Me.YourControl = Nz(DCount("IDField", "Orders", "Customer='" & Me.Customer & "'"),0)
End Sub
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 39888467
Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now