Counting records in a form

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

Guest

I have av form like this:
Name Adress Pulje Tropp
Tom Kongsb 1A 1
Bill Dramm 1A 1
Jon Dramm 2B 2
I want a textbox to display how many records are Pulje = 1A
The only count code that works so far is =Count(*). But this code
counts all the records, whereas I want to count only those where Pulje =1A

How do I do this??
 
Hi,

My name is Amy Vargo. Thank you for using the Microsoft Access Newsgroups.

You can use the DCount() function in an expression as the Control Source of
an unbound textbox. You can use the DCount function to determine the
number of records that are in a specified set of records (a domain) and can
use criteria. You can use the DCount function in Visual Basic, a macro, a
query expression, or a calculated control.

DCount(expr, domain, [criteria])

For example, you could use the DCount function to return the number of
records in an Orders table that correspond to orders where the ShipRegion
is CA.

=DCount("[OrderID]", "Orders", "[ShipRegion] = 'CA'")

For more information about the DCount function, you can search in Access
Help under the topic "DCount".

I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Amy Vargo
Microsoft Access Engineer


This posting is provided 'AS IS' with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.
 
Eric said:
I have av form like this:
Name Adress Pulje Tropp
Tom Kongsb 1A 1
Bill Dramm 1A 1
Jon Dramm 2B 2
I want a textbox to display how many records are Pulje = 1A
The only count code that works so far is =Count(*). But this code
counts all the records, whereas I want to count only those where Pulje =1A


If you only want to count the 1A records in the form, then
you can use one of these expressions in a text box in the
form's header/footer section:

=Count(IIf(Pulje="1A", 1, Null))
or
=Sum(IIf(Pulje="1A", 1, 0))
or
=Abs(Sum(Pulje="1A"))

However, if you want to count all of the various values for
the Pulje field, you should create a subform based on a
Totals type query. Keeping the subform synchronized with
the main form can get complicated if the main form can be
filtered "on the fly".
 
Back
Top