Count uniq records and assign to a control

  • Thread starter Thread starter Song Su
  • Start date Start date
S

Song Su

SID is the field of underline query of a form (have many duplicates). I want
to count number of uniq SID and assign the result to TotalStudent control on
the form. Please help. Thanks

- Song
 
SID is the field of underline query of a form (have many duplicates). I want
to count number of uniq SID and assign the result to TotalStudent control on
the form. Please help. Thanks

- Song
Maybe with a saved query such as
Query1: SELECT DISTINCT SID FROM UnderlyingQuery;

=DCOUNT("SID","Query1")
 
Song said:
SID is the field of underline query of a form (have many duplicates). I want
to count number of uniq SID and assign the result to TotalStudent control on
the form. Please help. Thanks


You need a separate query to calculate a unique count.

query: DistinctCount
SELECT Count(*) As SIDcount
FROM (SELECT DISTINCT SID FROM formquery)

Then the TotalStudent text box can use the exression:
=DLookup("SIDcount", "DistinctCount")
 
Back
Top