By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 1,904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

Can this Criteria be Added to a DCount Expression?

P: n/a
I was able to glean syntax online for a DCount on a form that counts
the number of 'misbehavior' incidents for students for the current
day:

=DCount("StudentID","Incidents","StudentID=" & Forms!
frmIncidentSummary!StudentID & " and
datediff(""d"",IncidentDateTime,date())=0").

However, there is another field, named IntType, that categorizes the
types of incdents. How can this additional criteria, for instance,
Forms!frmIncidentSummary!IntType = 1 or IntType = 3 or IntType = 5 be
added into the DCount, counting the number AND types of incidents for
students for the current day?

Where IntType 1 = Hallway, IntType 3 = SRoom, and IntType 5 = Off-
Grounds Suspension

IncTypeID 1 2 3 4 5
IncType --- Hallway SBooth SRoom On-Ground Off-
Ground
IncAbbreviation HAL SB SR ON OFF

Therefore, there would be 5 additional columns with 5 DCounts
summarizing this info. Thanks
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jun 20, 4:23*am, 6afraidbecause...@gmail.com wrote:
I was able to glean syntax online for a DCount on a form that counts
the number of 'misbehavior' incidents for students for the current
day:

=DCount("StudentID","Incidents","StudentID=" & Forms!
frmIncidentSummary!StudentID & " and
datediff(""d"",IncidentDateTime,date())=0").

However, there is another field, named IntType, that categorizes the
types of incdents. *How can this additional criteria, for instance,
Forms!frmIncidentSummary!IntType = 1 or IntType = 3 or IntType = 5 be
added into the DCount, counting the number AND types of incidents for
students for the current day?

Where IntType 1 = Hallway, IntType 3 = SRoom, and IntType 5 = Off-
Grounds Suspension

IncTypeID * * 1 * * 2 * * 3 * * 4 * * 5
IncType * * --- * * Hallway * * SBooth * * SRoom * * On-Ground * * Off-
Ground
IncAbbreviation * * HAL * * SB * * SR * * ON * * OFF

Therefore, there would be 5 additional columns with 5 DCounts
summarizing this info. *Thanks
do this works
=DCount("StudentID","Incidents","StudentID=" & Forms!
frmIncidentSummary!StudentID & " and
datediff(""d"",IncidentDateTime,date())=0" & " and intType = 1").

note, dcount() are not performance efficient, maybe you could add
these to the query on which the form is based ?
Jun 27 '08 #2

P: n/a
Thanks a lot Roger! I couldn't figure out the correct syntax with the
quotes.

I don't normally use such calculations - How can such a formula be put
into the underlying query? I tried making an expression, but it
appears too complex...

Jun 27 '08 #3

P: n/a
On Jun 20, 4:59*am, 6afraidbecause...@gmail.com wrote:
Thanks a lot Roger! *I couldn't figure out the correct syntax with the
quotes.

I don't normally use such calculations - How can such a formula be put
into the underlying query? *I tried making an expression, but it
appears too complex...
what is your current query for this form ?
Jun 27 '08 #4

P: n/a
I'm getting a syntax error on there Where statement, but I'll play
around with it. Thanks for your time and pointing me in the right
direction. Best
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.