Compare number of records read vs number returned access

G

Greg

I need to report the number of records matching a selection query vs the
number that don't.

eg: 'There are 24 records out of 456 that match your criteria'
 
J

John Spencer

In the report footer add a text control.

Set the control source to
= "There are " & count(*) & " records out of " &
DCount("*","YourTableName") & " that match your criteria"

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
G

Greg

John - thanks very much, one final tweak is required, In 2003 Access DCount
has a third parameter, criteria. My attempts to get the total record count
to be restricted to a date range on the tdate field of my table have only
produced a rather unhelpful - 'error' symbol.

I need to restrict the sum of the total records to the same date range as
the report. My construction is
Dcount("*","Tablename","tablename.tdate>"2008-12-31" and
tablename.tdate<"2009-02-01") to capture all the January only records.

Thanks so much for your assistance.
 
J

John Spencer (MVP)

You were close. Dates should be delimited by # characters instead of "
characters in Access. So try the following expression.

Dcount("*","Tablename","tdate>#2008-12-31# and tdate<#2009-02-01#")

The trick will be to make those dates dynamic. That might be possible
depending on your reports source. Or perhaps you can use this little trick if
you are displaying the date in the report.

Dcount("*","Tablename","tdate>=" & Format(Min(TDate),"\#yyyy-mm-dd\#") & " and
tdate<= " & Format(Max(TDate),"\#yyyy-mm-dd\#"))



John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
G

Greg

Perfect !!! - Thanks !!!

John Spencer (MVP) said:
You were close. Dates should be delimited by # characters instead of "
characters in Access. So try the following expression.

Dcount("*","Tablename","tdate>#2008-12-31# and tdate<#2009-02-01#")

The trick will be to make those dates dynamic. That might be possible
depending on your reports source. Or perhaps you can use this little trick if
you are displaying the date in the report.

Dcount("*","Tablename","tdate>=" & Format(Min(TDate),"\#yyyy-mm-dd\#") & " and
tdate<= " & Format(Max(TDate),"\#yyyy-mm-dd\#"))



John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top