DCount Help on Subreport

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
 
K

Klatuu

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

Douglas J. Steele

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
 
K

Klatuu

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
 
M

Marshall Barton

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 & "' ")
 
W

WPW07

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 & "' ")
 

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