View Single Post
  #8  
Old May 15th, 2010, 02:18 AM posted to microsoft.public.access.reports
Steve[_77_]
external usenet poster
 
Posts: 1,017
Default Record count in report w/o records

Look again at the OP's post. The report is not open with a where clause.
DLookup is based on a self-contained query with it's own criteria. DLookup
will certainly work!

Steve


"Duane Hookom" wrote in message
...
This won't work if you open the report with a where condition that filters
the records displayed in a report. I almost always use code like:

Dim strWhere as String
strWhere = "[DateField] Between #" & me.txtStart & "# AND #" & Me.txtEnd &
"#"
DoCmd.OpenReport "rptMyReport", acPreview, , strWhere

Using DCount() will not understand the where condition so it is very
possible the displayed value will be greater than the actual number of
records returned in the report.

--
Duane Hookom
Microsoft Access MVP


"Steve" wrote:

Hello Ray,

DCount("*","NameOfYourQuery") will give you the number of records in
NameOfYourQuery. Add an unbound textbox to your report and put =
DCount("*","NameOfYourQuery") in the control source.

Steve




"swansonray" wrote in message
...
Hi all,

In the detail section of a report I want to display the number of
records
a
query returns.

Example query named "support"
In the report I want to display Support = "number of records in query"
and then continue with the number of records in other querys with
different
names.

Thank you for your assistance.

Ray Swanson
Lemoore, CA



.