Solved

DCount Syntax

Posted on 2014-02-26
4
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 85
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 85

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

729 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