counting total orders on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to create a calculated field on a form that counts the total number of
orders for each customer.
I'm assuming i use the count function, but not unsure and unsure of syntax.
Thanks for help.
 
Will the count be for all customers or for the current customer on the form?
Assuming it is for the current customer on the form. You could do a DCount
in the Form's Current event:
Me.txtCustOrders = Nz(DCount("*", "OrdersTable", _
"[CustID] = '" & Me.txtCustID & "'"),0)

Use the Nz function so that if the customer has no orders it will return 0
instead of Null
I made up the names, so you will have to modify the code to use your names.
OrdersTable is the name of the table that has orders in it (Clever naming,
right)
CustID is the field name for the unique identify for the customer in the
orders table
Me.txtCustOrders is the control where the count will be displayed
Me.txtCustID is the control where the identifier for the customer is displayed
 
Back
Top