PC Review


Reply
Thread Tools Rate Thread

DCount in a Report with Parameter

 
 
Tanya
Guest
Posts: n/a
 
      26th Jan 2006
I am using a query with a parameter as the source for a report. The
parameter prompts for the date a class was held and the class code. In
the report I want to calculate the number of people who registered for
and actually attended that class. I was trying to use the following
DCount function, but I keep getting an error message:
=DCount("[Registrants]","Class ListQry","[Date]=[Enter class date]").
Registrants is the name of the field I want to count, Class ListQry is
the query name and [Enter date] is the parameter as it appears in the
query. Any idea why this is creating an error. Thanks in advance.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2hhcmtieXRl?=
Guest
Posts: n/a
 
      26th Jan 2006
I've not dealt with it, because of using naming conventions, but I think you
may need brackets around your query name, to accomodate the space in the name.

Access does not like spaces in its names.

Sharkbyte


"Tanya" wrote:

> I am using a query with a parameter as the source for a report. The
> parameter prompts for the date a class was held and the class code. In
> the report I want to calculate the number of people who registered for
> and actually attended that class. I was trying to use the following
> DCount function, but I keep getting an error message:
> =DCount("[Registrants]","Class ListQry","[Date]=[Enter class date]").
> Registrants is the name of the field I want to count, Class ListQry is
> the query name and [Enter date] is the parameter as it appears in the
> query. Any idea why this is creating an error. Thanks in advance.
>
>

 
Reply With Quote
 
fredg
Guest
Posts: n/a
 
      26th Jan 2006
On 26 Jan 2006 08:42:31 -0800, Tanya wrote:

> I am using a query with a parameter as the source for a report. The
> parameter prompts for the date a class was held and the class code. In
> the report I want to calculate the number of people who registered for
> and actually attended that class. I was trying to use the following
> DCount function, but I keep getting an error message:
> =DCount("[Registrants]","Class ListQry","[Date]=[Enter class date]").
> Registrants is the name of the field I want to count, Class ListQry is
> the query name and [Enter date] is the parameter as it appears in the
> query. Any idea why this is creating an error. Thanks in advance.


Several mistakes.
1) Your table name ("Class ListQry") contains a space. Enclose the
name within brackets inside the quotes, i.e. "[Class ListQry]".

2) Date is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

3) The [Enter Class Date] parameter prompt must be concatenated into
the criteria, otherwise Access is looking for a literal "Enter Class
Date" value.

4) A date value must be enclosed within the date delimiter symbol #.

Try:
=DCount("[Registrants]","[Class ListQry]","[DateField] = #" & [Enter
Class Date] & "#")

Note: I've used a generic [DateField] in the Where clause. Change it
to whatever name you change your [Date] field to.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
Tanya
Guest
Posts: n/a
 
      2nd Feb 2006
Fred,

Thanks for the pointers. I changed the field name from Date to
ClassDate and edited the DCount function as you recommended. It reads:
=DCount("[Registrants]","[Class ListQry]","[ClassDate]=#" & [Please
enter class date] & "#"). Unfortunately, I still get #Error when I
preview the report. I put the control containing this function in a
group footer. Any ideas?

 
Reply With Quote
 
fredg
Guest
Posts: n/a
 
      2nd Feb 2006
On 2 Feb 2006 11:38:31 -0800, Tanya wrote:

> Fred,
>
> Thanks for the pointers. I changed the field name from Date to
> ClassDate and edited the DCount function as you recommended. It reads:
> =DCount("[Registrants]","[Class ListQry]","[ClassDate]=#" & [Please
> enter class date] & "#"). Unfortunately, I still get #Error when I
> preview the report. I put the control containing this function in a
> group footer. Any ideas?



The DCount syntax looks OK to me.

I just ran a test in a report and I got the correct count from a
query.

1) Is a complete valid date being entered, i.e. 1/15/2006?

2) Make sure the Name of this control is NOT "Registrants" or
"ClassDate". Access gets confused when the name of the control is the
same as the name of any field in it's control source.

3) Are there fields in the query named "Registrants" and "ClassDate"?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using DCount in report with parameter qry Flopbot Microsoft Access Reports 1 14th Aug 2009 05:57 AM
Checking if txtbox is null and DCount parameter Rob W Microsoft Access 3 18th Feb 2008 09:59 PM
Using Dcount function based on an access parameter query =?Utf-8?B?S2lsdGVka2l3aQ==?= Microsoft Access Reports 4 8th Feb 2007 02:51 AM
DCount in Text box from a parameter query =?Utf-8?B?UEQ=?= Microsoft Access 4 24th Jul 2006 02:01 PM
Dcount in report with parameter again Tanya Microsoft Access 1 8th Mar 2006 11:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:14 AM.