Solved

DCount Syntax

Posted on 2014-02-26
4
327 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

810 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