Can this Criteria be Added to a DCount Expression?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 6afraidbecause789@gmail.com

    Can this Criteria be Added to a DCount Expression?

    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("Studen tID","Incidents ","StudentI D=" & Forms!
    frmIncidentSumm ary!StudentID & " and
    datediff(""d"", IncidentDateTim e,date())=0").

    However, there is another field, named IntType, that categorizes the
    types of incdents. How can this additional criteria, for instance,
    Forms!frmIncide ntSummary!IntTy pe = 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
  • Roger

    #2
    Re: Can this Criteria be Added to a DCount Expression?

    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("Studen tID","Incidents ","StudentI D=" & Forms!
    frmIncidentSumm ary!StudentID & " and
    datediff(""d"", IncidentDateTim e,date())=0").
    >
    However, there is another field, named IntType, that categorizes the
    types of incdents.  How can this additional criteria, for instance,
    Forms!frmIncide ntSummary!IntTy pe = 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("Studen tID","Incidents ","StudentI D=" & Forms!
    frmIncidentSumm ary!StudentID & " and
    datediff(""d"", IncidentDateTim e,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 ?

    Comment

    • 6afraidbecause789@gmail.com

      #3
      Re: Can this Criteria be Added to a DCount Expression?

      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...

      Comment

      • Roger

        #4
        Re: Can this Criteria be Added to a DCount Expression?

        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 ?

        Comment

        • 6afraidbecause789@gmail.com

          #5
          Re: Can this Criteria be Added to a DCount Expression?

          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

          Comment

          Working...