DCount Help on Subreport

  • Thread starter Thread starter WPW07
  • Start date Start date
W

WPW07

Hello,

I'm stuck with a Dcount function. I'm trying to count the number of
choices for a given event where the choice=1. This is in the EventID
footer of a subreport. This is what I have:

=DCount("[Choice]","qryEventChoices","[Choice]=1" And "[EventID] = " &
[EventID]).

EventID is a string.

It's returning ALL choices (4000) in the query instead of just those
with a value of 1 (27 for event A)

Thanks
 
Since EventID is a string, you need to correct the syntax:
=DCount("[Choice]","qryEventChoices","[Choice]=1" And "[EventID] = """ &
[EventID] & """").
 
Not only that, but the And needs to be inside the quotes:

=DCount("[Choice]","qryEventChoices","[Choice]=1 And [EventID] = """ &
[EventID] & """").


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Klatuu said:
Since EventID is a string, you need to correct the syntax:
=DCount("[Choice]","qryEventChoices","[Choice]=1" And "[EventID] = """ &
[EventID] & """").

--
Dave Hargis, Microsoft Access MVP


WPW07 said:
Hello,

I'm stuck with a Dcount function. I'm trying to count the number of
choices for a given event where the choice=1. This is in the EventID
footer of a subreport. This is what I have:

=DCount("[Choice]","qryEventChoices","[Choice]=1" And "[EventID] = " &
[EventID]).

EventID is a string.

It's returning ALL choices (4000) in the query instead of just those
with a value of 1 (27 for event A)

Thanks
 
Thanks, Doug
--
Dave Hargis, Microsoft Access MVP


Douglas J. Steele said:
Not only that, but the And needs to be inside the quotes:

=DCount("[Choice]","qryEventChoices","[Choice]=1 And [EventID] = """ &
[EventID] & """").


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Klatuu said:
Since EventID is a string, you need to correct the syntax:
=DCount("[Choice]","qryEventChoices","[Choice]=1" And "[EventID] = """ &
[EventID] & """").

--
Dave Hargis, Microsoft Access MVP


WPW07 said:
Hello,

I'm stuck with a Dcount function. I'm trying to count the number of
choices for a given event where the choice=1. This is in the EventID
footer of a subreport. This is what I have:

=DCount("[Choice]","qryEventChoices","[Choice]=1" And "[EventID] = " &
[EventID]).

EventID is a string.

It's returning ALL choices (4000) in the query instead of just those
with a value of 1 (27 for event A)

Thanks
 
WPW07 said:
Hello,

I'm stuck with a Dcount function. I'm trying to count the number of
choices for a given event where the choice=1. This is in the EventID
footer of a subreport. This is what I have:

=DCount("[Choice]","qryEventChoices","[Choice]=1" And "[EventID] = " &
[EventID]).

EventID is a string.

It's returning ALL choices (4000) in the query instead of just those
with a value of 1 (27 for event A)


Try something more like:

=DCount("Choice","qryEventChoices","Choice=1 And EventID='"
& EventID & "' ")
 
Thank you for your help. That worked perfectly...



WPW07 said:
I'm stuck with a Dcount function.  I'm trying to count the number of
choices for a given event where the choice=1.  This is in the EventID
footer of a subreport.  This is what I have:
=DCount("[Choice]","qryEventChoices","[Choice]=1" And "[EventID] =" &
[EventID]).
EventID is a string.
It's returning ALL choices (4000) in the query instead of just those
with a value of 1 (27 for event A)

Try something more like:

=DCount("Choice","qryEventChoices","Choice=1 And EventID='"
& EventID & "' ")
 
Back
Top